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

runtime.Caller crashes on large inputs #176

Closed
rsc opened this issue Nov 14, 2009 · 8 comments
Closed

runtime.Caller crashes on large inputs #176

rsc opened this issue Nov 14, 2009 · 8 comments

Comments

@rsc
Copy link
Contributor

rsc commented Nov 14, 2009

From the documentation I thought that runtime.Caller(frame) will
return false when it is not possible to obtain information - instead
it causes program to crash past call stack top :

package main

import (
       "fmt";
       "runtime";
       "strings"
)

func main() {
       foo()
}

func foo() {
       bar()
}

func bar() {
       for i := 0; ; i++ {
               _, file, line, ok := runtime.Caller(i);
               if ok {
                       path := strings.Split(file, "/", 0);
                       fmt.Printf("%s : %d\n", path[len(path)-1], line);
               } else {
                       break;
               }
       }
}

results in

stacktrace.go : 19
stacktrace.go : 14
stacktrace.go : 10
asm.s : 81
proc.c : 135
Bus error

Also, Caller() doc says 'The argument is the number of stack frames to
ascend, with 1 identifying the the caller of Caller', while in fact,
it looks like 0 is the caller of Caller.

http://groups.google.com/group/golang-nuts/t/8626dabf2b80d453
@rsc
Copy link
Contributor Author

rsc commented Nov 15, 2009

Comment 1:

Status changed to Started.

@rsc
Copy link
Contributor Author

rsc commented Nov 15, 2009

Comment 2:

This issue was closed by revision 0911913.

Status changed to Fixed.

Merged into issue #-.

@gopherbot
Copy link
Contributor

Comment 3 by emage@spamcop.net:

I'm experiencing this again, at rev 4301:383e139ab09f
My test program:
package main
import "fmt"
import "runtime"
func main() {
        for i := int(0); true; i++ {
                pc, file, line, ok := runtime.Caller(i);
                if !ok {
                        break
                }
                fmt.Println(pc, file, line);
        }
}
GOOS=linux GOARCH=386
failure is at runtime.Caller+0x121 traceback.c:133

@gopherbot
Copy link
Contributor

Comment 4 by wmundt42:

Let me revise that: $GOROOT/src/pkg/runtime/386/traceback.c:133

@ianlancetaylor
Copy link
Contributor

Comment 5:

Status changed to New.

@rsc
Copy link
Contributor Author

rsc commented Dec 3, 2009

Comment 6:

http://golang.org/cl/166044
Whoops - only fixed amd64 last time.

Status changed to Started.

@rsc
Copy link
Contributor Author

rsc commented Dec 4, 2009

Comment 7:

This issue was closed by revision cf37254.

Status changed to Fixed.

Merged into issue #-.

@gopherbot
Copy link
Contributor

Comment 8:

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

@rsc rsc added the fixed label May 30, 2014
@rsc rsc self-assigned this May 30, 2014
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants