coap-go icon indicating copy to clipboard operation
coap-go copied to clipboard

Server segfaults upon GET .well-known/core

Open bsmelo opened this issue 6 years ago • 5 comments

I was able to go run main.go, but when I used Firefox Copper to retrieve the available resources on the sample application, although I got a response at Firefox, the application crashed with the following details:

 $ go run main.go
2017/08/23 15:04:58 Allocated go memory at 0x7e7210
CoAP_init!
CoAP Available memory: 4096 bytes at 0x7e7210
CoAP Interaction size: 128 byte
CoAP_Res_t size: 64 byte
CoAP_Message_t size: 48 byte
CoAP_option_t size: 24 byte
CoAP_Observer_t size: 56 byte
2017/08/23 15:04:58 Init liblobarocoap
2017/08/23 15:04:58 Creating UDP CoAP socket
- CoAP_CreateInterfaceSocket(): listening... IfID: 1 
2017/08/23 15:05:21 Received UDP Data@ 127.0.0.1 : 38403 => [64 1 40 120 187 46 119 101 108 108 45 107 110 111 119 110 4 99 111 114 101]

<<<<<<<<<<<<<<<<<<<<<<
New Datagram received [21 Bytes], Interface #1
Sending Endpoint: IPv4, 127.0.0.1:38403
----------------------------
*Type: CON (0x00)
*Token: 0 Byte -> 0
*Code: 0.01 (0x01) [REQ_GET]
*MessageId: 10360
*Option #11 (Length=11) -> .[2e] w[77] e[65] l[6c] l[6c] -[2d] k[6b] n[6e] o[6f] w[77] n[6e]
*Option #11 (Length=4) -> c[63] o[6f] r[72] e[65]
*Timestamp: 1503511521
----------------------------
<<<<<<<<<<<<<<<<<<<<<<
- WellKnown_GetHandler(): res cnt:1 temp alloc:192

>>>>>>>>>>>>>>>>>>>>>>
Send Message [27 Bytes], Interface #1
Receiving Endpoint: IPv4, 127.0.0.1:38403
0x60(`) 0x45(E) 0x28(() 0x78(x) 0xc1(�) 0x28(() 0xff(�) 0x3c(<) 0x2e(.) 0x77(w) 0x65(e) 0x6c(l) 0x6c(l) 0x2d(-) 0x6b(k) 0x6e(n) 0x6f(o) 0x77(w) 0x6e(n) 0x2f(/) 0x63(c) 0x6f(o) 0x72(r) 0x65(e) 0x2f(/) 0x3e(>) 0x2c(,) 
----------------------------
*Type: ACK (0x02)
*Token: 0 Byte -> 0
*Code: 2.05 (0x45) 
*MessageId: 10360
*Option #12 (Length=1) -> ([28]
*Payload (20 Byte): "<.well-2017/08/23 15:05:21 Sending UDP Data to  127.0.0.1:38403  =>  [96 69 40 120 193 40 255 60 46 119 101 108 108 45 107 110 111 119 110 47 99 111 114 101 47 62 44]
known/core/>,"
*Timestamp: 0
----------------------------
>>>>>>>>>>FAIL>>>>>>>>>>
(!!!) SendResp(): Internal socket error on sending response! MiD: 10360Releasing Interaction...
- CoAP mem usage: dynamic: [544] dynamic+static: [544] free: [3548] biggest shunk: [139852725095900] get/releases: [139852725092363|2]
SIGSEGV: segmentation violation
PC=0x40586d
signal arrived during cgo execution

runtime.cgocallbackg()
        /usr/lib/go/src/pkg/runtime/cgocall.c:267 +0x89 fp=0x7f329a4e7ec0
runtime.cgocallback_gofunc(0x40edf3, 0x405730, 0x7f329a4e7f38)
        /usr/lib/go/src/pkg/runtime/asm_amd64.s:711 +0x67 fp=0x7f329a4e7ed0
runtime.asmcgocall(0x405730, 0x7f329a4e7f38)
        /usr/lib/go/src/pkg/runtime/asm_amd64.s:618 +0x2d fp=0x7f329a4e7ed8
runtime.cgocall(0x405730, 0x7f329a4e7f38)
        /usr/lib/go/src/pkg/runtime/cgocall.c:149 +0x133 fp=0x7f329a4e7f20
github.com/Lobaro/coap-go/coap-old._Cfunc_CoAP_doWork(0x45bce8)
        github.com/Lobaro/coap-go/coap-old/_obj/_cgo_defun.c:104 +0x31 fp=0x7f329a4e7f38
github.com/Lobaro/coap-go/coap-old.doWork()
        /home/bruno/go/src/github.com/Lobaro/coap-go/coap-old/go_api.go:74 +0x1a fp=0x7f329a4e7f40
github.com/Lobaro/coap-go/coap-old.func·001()
        /home/bruno/go/src/github.com/Lobaro/coap-go/coap-old/go_api.go:47 +0x28 fp=0x7f329a4e7fa0
runtime.goexit()
        /usr/lib/go/src/pkg/runtime/proc.c:1394 fp=0x7f329a4e7fa8
created by github.com/Lobaro/coap-go/coap-old.init·1
        /home/bruno/go/src/github.com/Lobaro/coap-go/coap-old/go_api.go:51 +0x26

goroutine 1 [sleep]:
time.Sleep(0x5f5e100)
        /usr/lib/go/src/pkg/runtime/time.goc:31 +0x31
main.handleUdpIncoming(0xc210000090)
        /home/bruno/Dropbox/coap-apps/todo/coap-go/main.go:55 +0x3ea
main.main()
        /home/bruno/Dropbox/coap-apps/todo/coap-go/main.go:29 +0x384

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

goroutine 5 [chan receive]:
main.handleUdpOutgoing(0xc210000090)
        /home/bruno/Dropbox/coap-apps/todo/coap-go/main.go:34 +0x3e
created by main.main
        /home/bruno/Dropbox/coap-apps/todo/coap-go/main.go:28 +0x374

rax     0x0
rbx     0x7f3200000000
rcx     0x88
rdx     0x0
rdi     0x7f329a271400
rsi     0x7f329a2729e0
rbp     0x7ef2e0
rsp     0x7f3298daadd0
r8      0x7f3298dab700
r9      0x383933315b203a73
r10     0x7f329a26f6a0
r11     0x0
r12     0x0
r13     0x0
r14     0x65
r15     0x10
rip     0x40586d
rflags  0x10206
cs      0x33
fs      0x0
gs      0x0
exit status 2

I see it's a socket error, but it also seems to be coming from cgo (as I said, I have basically zero knowledge of go itself)... Is this a problem on the code (i.e. actually socket-related), or something related to my setup (i.e. compiler, architecture, OS...)?

Thanks & Regards, Bruno Melo.

bsmelo avatar Aug 23 '17 18:08 bsmelo