Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

encoding/asn1: Marshal panics if given *big.Int == nil #17461

Closed
hirochachacha opened this issue Oct 16, 2016 · 2 comments
Closed

encoding/asn1: Marshal panics if given *big.Int == nil #17461

hirochachacha opened this issue Oct 16, 2016 · 2 comments
Assignees
Milestone

Comments

@hirochachacha
Copy link
Contributor

@hirochachacha hirochachacha commented Oct 16, 2016

Please answer these questions before submitting your issue. Thanks!

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

package main

import (
    "encoding/asn1"
    "math/big"
)

var B *big.Int

func main() {
    asn1.Marshal(B)
}

What did you expect to see?

no panic.

What did you see instead?

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x9ab8a]

goroutine 1 [running]:
panic(0xb9280, 0x13d250)
/Users/hiro/go/src/runtime/panic.go:527 +0x1a0
encoding/asn1.makeBigInt(0x0, 0x0, 0x16)
/Users/hiro/go/src/encoding/asn1/marshal.go:154 +0x3a
encoding/asn1.makeBody(0xcf640, 0x0, 0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1e6038, ...)
/Users/hiro/go/src/encoding/asn1/marshal.go:412 +0x1301
encoding/asn1.makeField(0xcf640, 0x0, 0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/hiro/go/src/encoding/asn1/marshal.go:596 +0x2b4
encoding/asn1.Marshal(0xcf640, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc4200001a0)
/Users/hiro/go/src/encoding/asn1/marshal.go:641 +0xe6
main.main()
/Users/hiro/a.go:15 +0x39
exit status 2

Does this issue reproduce with the latest release (go1.7.1)?

System details

go version devel +05cbf45 Sun Oct 16 13:47:13 2016 +0900 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/hiro/.go"
GORACE=""
GOROOT="/Users/hiro/go"
GOTOOLDIR="/Users/hiro/go/pkg/tool/darwin_amd64"
TERM="dumb"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wq/dwn8hs0x7njbzty9f68y61700000gn/T/go-build830555530=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
uname -v: Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G1004
lldb --version: lldb-360.1.50
gdb --version: GNU gdb (GDB) 7.11.1
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 16, 2016

CL https://golang.org/cl/31121 mentions this issue.

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Oct 17, 2016

According to https://play.golang.org/p/lyU5aXsRpb this also paniced with the old marshal code in Go 1.7 and earlier.

So it's not like this is a regression in Go 1.8's new marshalling code.

I'll let @agl decide.

/cc @odeke-em

@quentinmit quentinmit added this to the Go1.8Maybe milestone Oct 17, 2016
@gopherbot gopherbot closed this in 4a5b3ef Oct 17, 2016
@golang golang locked and limited conversation to collaborators Oct 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.