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

space.DebugDraw causes sigsegv #1

Closed
johnsto opened this issue Jul 12, 2014 · 3 comments
Closed

space.DebugDraw causes sigsegv #1

johnsto opened this issue Jul 12, 2014 · 3 comments

Comments

@johnsto
Copy link

johnsto commented Jul 12, 2014

Still investigating cause of this, here's test code using a minimal implementation of SpaceDebugDrawOptions.

package main

import (
    cp "gopkg.in/slimsag/cp.v1"
)

func main() {
    space := cp.SpaceNew()

    body := cp.BodyNew(10, cp.MomentForCircle(1, 0, 32, cp.V(0, 0)))
    space.AddBody(body)
    space.AddShape(body.CircleShapeNew(32, cp.V(0, 0)))

    debugDraw := &cp.SpaceDebugDrawOptions{
        DrawCircle: func(pos cp.Vect, angle, radius float64,
            outlineColor, fillColor cp.SpaceDebugColor, data interface{}) {
        },
        DrawSegment: func(a, b cp.Vect, color cp.SpaceDebugColor,
            data interface{}) {
        },
        DrawFatSegment: func(a, b cp.Vect, radius float64,
            outlineColor, fillColor cp.SpaceDebugColor, data interface{}) {
        },
        DrawPolygon: func(verts []cp.Vect, radius float64,
            outlineColor, fillColor cp.SpaceDebugColor, data interface{}) {
        },
        DrawDot: func(size float64, pos cp.Vect,
            color cp.SpaceDebugColor, data interface{}) {
        },
        ColorForShape: func(shape *cp.Shape, data interface{}) cp.SpaceDebugColor {
            return cp.SpaceDebugColor{}
        },
        Flags:               cp.SPACE_DEBUG_DRAW_SHAPES,
        ShapeOutlineColor:   cp.SpaceDebugColor{},
        ConstraintColor:     cp.SpaceDebugColor{},
        CollisionPointColor: cp.SpaceDebugColor{},
        Data:                struct{}{},
    }

    space.DebugDraw(debugDraw)
}

Which results in the following crash

SIGSEGV: segmentation violation                                                           
PC=0x7f7578                                                                               
signal arrived during cgo execution                                                       

runtime.cgocall(0x410c40, 0x7fa005321ed8)                                                 
        /usr/local/go/src/pkg/runtime/cgocall.c:149 +0x11b fp=0x7fa005321ec0              
gopkg.in/slimsag/cp%2ev1._Cfunc_cpSpaceDebugDraw(0x1245290, 0xc210042000)                 
        gopkg.in/slimsag/cp.v1/_obj/_cgo_defun.c:2510 +0x31 fp=0x7fa005321ed8             
gopkg.in/slimsag/cp%2ev1.(*Space).DebugDraw(0xc210036030, 0xc210041000)                   
        /home/dave/gocode/src/gopkg.in/slimsag/cp.v1/space.go:662 +0x117 fp=0x7fa005321ef8
main.main()                                                                               
        /tmp/crash/crash.go:40 +0x1f6 fp=0x7fa005321f48                   
runtime.main()                                                                            
        /usr/local/go/src/pkg/runtime/proc.c:220 +0x11f fp=0x7fa005321fa0                 
runtime.goexit()                                                                          
        /usr/local/go/src/pkg/runtime/proc.c:1394 fp=0x7fa005321fa8                       

goroutine 3 [syscall]:                                                                    
runtime.goexit()                                                                          
        /usr/local/go/src/pkg/runtime/proc.c:1394                                         

rax     0x0                                                                               
rbx     0xc210042000                                                                      
rcx     0x0                                                                               
rdx     0x5                                                                               
rdi     0x1245d00                                                                         
rsi     0xc210000008                                                                      
rbp     0x7fff8b917230                                                                    
rsp     0x7fff8b9171a8                                                                    
r8      0xc210001120                                                                      
r9      0x7fa005321e70                                                                    
r10     0x0                                                                               
r11     0x0                                                                               
r12     0x1245d00                                                                         
r13     0xc210000008                                                                      
r14     0x1245be0                                                                         
r15     0x0                                                                               
rip     0x7f7578                                                                          
rflags  0x10246                                                                           
cs      0x33                                                                              
fs      0x0                                                                               
gs      0x0                                                                               
exit status 2                                                                             

@slimsag
Copy link
Owner

slimsag commented Jul 13, 2014

Thanks for the bug report! I'll look into it ASAP.

Small note, you don't have to do:
import cp "gopkg.in/slimsag/cp.v1"

Just this will work (still imported as "cp"):
import "gopkg.in/slimsag/cp.v1"

Stephen

slimsag added a commit that referenced this issue Jul 13, 2014
pointers. Make all SpaceDebugDrawOptions struct fields optional in calls
to DebugDraw, as well.

Add documentation to DebugDraw(), and add a test to verify it is working.

Fixes issue #1.
@slimsag
Copy link
Owner

slimsag commented Jul 13, 2014

@johnsto, I've fixed the issues at hand with DebugDraw (there were several) and it should all be working now.

I've also added a test which could serve useful to you in the file debugdraw_test.go, please let me know if you still encounter any issues =) !

Stephen

@slimsag slimsag closed this as completed Jul 13, 2014
@johnsto
Copy link
Author

johnsto commented Jul 13, 2014

Cripes, that was quick. Much obliged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants