we've been configuring monitoring of our openshift origin cluster and noticed that when we oc get pods --all-namespaces that our router pods have a high (> 200) restart count over the past month.
NAMESPACE NAME READY STATUS RESTARTS AGE
default router-2-kactc 1/1 Running 231 23d
default router-2-liyxb 1/1 Running 212 23d
edit: I was able to track down logs just prior to the pod crashing
fatal error: concurrent map read and map write
goroutine 44 [running]:
runtime.throw(0x38e04e0, 0x21)
/usr/local/go/src/runtime/panic.go:530 +0x90 fp=0xc820991238 sp=0xc820991220
runtime.mapaccess2(0x2820680, 0xc820650480, 0xc8202995c0, 0x317ca60, 0xc82078c750)
/usr/local/go/src/runtime/hashmap.go:343 +0x5a fp=0xc820991280 sp=0xc820991238
reflect.mapaccess(0x2820680, 0xc820650480, 0xc8202995c0, 0xc820650480)
/usr/local/go/src/runtime/hashmap.go:993 +0x35 fp=0xc8209912b0 sp=0xc820991280
reflect.Value.MapIndex(0x2820680, 0xc820206240, 0x95, 0x2828680, 0xc8202995c0, 0x98, 0x0, 0x0, 0x0)
/usr/local/go/src/reflect/value.go:1041 +0x14a fp=0xc820991338 sp=0xc8209912b0
text/template.(*state).walkRange(0xc8209918c0, 0x329f660, 0xc820206230, 0x99, 0xc820143e80)
/usr/local/go/src/text/template/exec.go:327 +0x885 fp=0xc820991538 sp=0xc820991338
text/template.(*state).walk(0xc8209918c0, 0x329f660, 0xc820206230, 0x99, 0x7f161f2bd1b0, 0xc820143e80)
/usr/local/go/src/text/template/exec.go:226 +0x264 fp=0xc820991680 sp=0xc820991538
text/template.(*state).walk(0xc8209918c0, 0x329f660, 0xc820206230, 0x99, 0x7f161f300540, 0xc8206484e0)
/usr/local/go/src/text/template/exec.go:223 +0x6a1 fp=0xc8209917c8 sp=0xc820991680
text/template.(*Template).Execute(0xc82056ad40, 0x7f161f2b8370, 0xc820074378, 0x329f660, 0xc820206230, 0x0, 0x0)
/usr/local/go/src/text/template/exec.go:178 +0x2a7 fp=0xc820991908 sp=0xc8209917c8
github.com/openshift/origin/pkg/router/template.(*templateRouter).writeConfig(0xc82064a340, 0x0, 0x0)
/go/src/github.com/openshift/origin/pkg/router/template/router.go:283 +0x892 fp=0xc820991d48 sp=0xc820991908
github.com/openshift/origin/pkg/router/template.(*templateRouter).commitAndReload(0xc82064a340, 0x0, 0x0)
/go/src/github.com/openshift/origin/pkg/router/template/router.go:231 +0x14d fp=0xc820991db0 sp=0xc820991d48
github.com/openshift/origin/pkg/router/template.(*templateRouter).(github.com/openshift/origin/pkg/router/template.commitAndReload)-fm(0x0, 0x0)
/go/src/github.com/openshift/origin/pkg/router/template/router.go:157 +0x2e fp=0xc820991dd0 sp=0xc820991db0
github.com/openshift/origin/pkg/util/ratelimiter.(*RateLimitedFunction).handleOne(0xc820650390, 0x33272e0, 0xc820650390)
/go/src/github.com/openshift/origin/pkg/util/ratelimiter/ratelimiter.go:49 +0x48 fp=0xc820991e08 sp=0xc820991dd0
github.com/openshift/origin/pkg/util/ratelimiter.(*RateLimitedFunction).RunUntil.func1()
/go/src/github.com/openshift/origin/pkg/util/ratelimiter/ratelimiter.go:42 +0x6a fp=0xc820991e50 sp=0xc820991e08
k8s.io/kubernetes/pkg/util/wait.JitterUntil.func1(0xc8204cfc10)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:66 +0x4b fp=0xc820991e80 sp=0xc820991e50
k8s.io/kubernetes/pkg/util/wait.JitterUntil(0xc8204cfc10, 0x0, 0x0, 0xc82005a540)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:67 +0x68 fp=0xc820991f40 sp=0xc820991e80
k8s.io/kubernetes/pkg/util/wait.Until(0xc8204cfc10, 0x0, 0xc82005a540)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:47 +0x3e fp=0xc820991f68 sp=0xc820991f40
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc820991f70 sp=0xc820991f68
created by github.com/openshift/origin/pkg/util/ratelimiter.(*RateLimitedFunction).RunUntil
/go/src/github.com/openshift/origin/pkg/util/ratelimiter/ratelimiter.go:42 +0x7d
goroutine 1 [select (no cases), 129 minutes]:
github.com/openshift/origin/pkg/cmd/infra/router.(*TemplateRouterOptions).Run(0xc820079c80, 0x0, 0x0)
/go/src/github.com/openshift/origin/pkg/cmd/infra/router/template.go:203 +0x85e
github.com/openshift/origin/pkg/cmd/infra/router.NewCommandTemplateRouter.func1(0xc8200f8600, 0x5b9a280, 0x0, 0x0)
/go/src/github.com/openshift/origin/pkg/cmd/infra/router/template.go:111 +0x1ad
github.com/spf13/cobra.(*Command).execute(0xc8200f8600, 0xc82005e140, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/github.com/spf13/cobra/command.go:572 +0x85a
github.com/spf13/cobra.(*Command).ExecuteC(0xc8200f8600, 0xc8200f8600, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/github.com/spf13/cobra/command.go:662 +0x53f
github.com/spf13/cobra.(*Command).Execute(0xc8200f8600, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/github.com/spf13/cobra/command.go:618 +0x2d
main.main()
/go/src/github.com/openshift/origin/cmd/openshift/openshift.go:27 +0x180
goroutine 17 [syscall, 129 minutes, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1998 +0x1
goroutine 19 [chan receive]:
github.com/golang/glog.(*loggingT).flushDaemon(0x5b72140)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/github.com/golang/glog/glog.go:879 +0x67
created by github.com/golang/glog.init.1
/go/src/github.com/openshift/origin/Godeps/_workspace/src/github.com/golang/glog/glog.go:410 +0x297
goroutine 9 [syscall, 9 minutes]:
os/signal.signal_recv(0x7f161f2b4050)
/usr/local/go/src/runtime/sigqueue.go:116 +0x132
os/signal.loop()
/usr/local/go/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
/usr/local/go/src/os/signal/signal_unix.go:28 +0x37
goroutine 45 [select]:
k8s.io/kubernetes/pkg/client/cache.(*Reflector).watchHandler(0xc82041a0a0, 0x7f161f2d1d30, 0xc8208aabd0, 0xc820665bf0, 0xc8203f0060, 0xc82005ae40, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:320 +0x13f7
k8s.io/kubernetes/pkg/client/cache.(*Reflector).ListAndWatch(0xc82041a0a0, 0xc82005ae40, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:287 +0x125f
k8s.io/kubernetes/pkg/client/cache.(*Reflector).Run.func1()
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:160 +0x2c
k8s.io/kubernetes/pkg/util/wait.JitterUntil.func1(0xc8203f5200)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:66 +0x4b
k8s.io/kubernetes/pkg/util/wait.JitterUntil(0xc8203f5200, 0x3b9aca00, 0x0, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:67 +0x68
k8s.io/kubernetes/pkg/util/wait.Until(0xc8203f5200, 0x3b9aca00, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:47 +0x3e
created by k8s.io/kubernetes/pkg/client/cache.(*Reflector).Run
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:160 +0x84
goroutine 46 [select]:
k8s.io/kubernetes/pkg/client/cache.(*Reflector).watchHandler(0xc82041a1e0, 0x7f161f2d1d30, 0xc8208aa450, 0xc8205cdc00, 0xc8208c2000, 0xc82005ae40, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:320 +0x13f7
k8s.io/kubernetes/pkg/client/cache.(*Reflector).ListAndWatch(0xc82041a1e0, 0xc82005ae40, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:287 +0x125f
k8s.io/kubernetes/pkg/client/cache.(*Reflector).Run.func1()
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:160 +0x2c
k8s.io/kubernetes/pkg/util/wait.JitterUntil.func1(0xc8203f5260)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:66 +0x4b
k8s.io/kubernetes/pkg/util/wait.JitterUntil(0xc8203f5260, 0x3b9aca00, 0x0, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:67 +0x68
k8s.io/kubernetes/pkg/util/wait.Until(0xc8203f5260, 0x3b9aca00, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:47 +0x3e
created by k8s.io/kubernetes/pkg/client/cache.(*Reflector).Run
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/cache/reflector.go:160 +0x84
goroutine 47 [runnable]:
k8s.io/kubernetes/pkg/util/wait.JitterUntil(0xc8203f52e0, 0x0, 0x0, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:74 +0x13c
k8s.io/kubernetes/pkg/util/wait.Until(0xc8203f52e0, 0x0, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:47 +0x3e
k8s.io/kubernetes/pkg/util/wait.Forever(0xc8203f52e0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:41 +0x37
created by github.com/openshift/origin/pkg/router/controller.(*RouterController).Run
/go/src/github.com/openshift/origin/pkg/router/controller/controller.go:46 +0x1da
goroutine 48 [semacquire, 9 minutes]:
sync.runtime_Syncsemacquire(0xc8203e2418)
/usr/local/go/src/runtime/sema.go:241 +0x201
sync.(*Cond).Wait(0xc8203e2408)
/usr/local/go/src/sync/cond.go:63 +0x9b
github.com/openshift/origin/pkg/client/cache.(*EventQueue).Pop(0xc8203e23f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/openshift/origin/pkg/client/cache/eventqueue.go:273 +0xd9
github.com/openshift/origin/pkg/router/controller/factory.(*RouterControllerFactory).Create.func1(0x0, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/openshift/origin/pkg/router/controller/factory/factory.go:71 +0x42
github.com/openshift/origin/pkg/router/controller.(*RouterController).HandleEndpoints(0xc82064d540)
/go/src/github.com/openshift/origin/pkg/router/controller/controller.go:91 +0x30
github.com/openshift/origin/pkg/router/controller.(*RouterController).HandleEndpoints-fm()
/go/src/github.com/openshift/origin/pkg/router/controller/controller.go:47 +0x20
k8s.io/kubernetes/pkg/util/wait.JitterUntil.func1(0xc8203f52f0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:66 +0x4b
k8s.io/kubernetes/pkg/util/wait.JitterUntil(0xc8203f52f0, 0x0, 0x0, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:67 +0x68
k8s.io/kubernetes/pkg/util/wait.Until(0xc8203f52f0, 0x0, 0xc82005ae40)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:47 +0x3e
k8s.io/kubernetes/pkg/util/wait.Forever(0xc8203f52f0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/util/wait/wait.go:41 +0x37
created by github.com/openshift/origin/pkg/router/controller.(*RouterController).Run
/go/src/github.com/openshift/origin/pkg/router/controller/controller.go:47 +0x239
goroutine 49 [chan receive, 9 minutes]:
github.com/openshift/origin/pkg/util/proc.StartReaper.func1()
/go/src/github.com/openshift/origin/pkg/util/proc/reaper.go:23 +0x193
created by github.com/openshift/origin/pkg/util/proc.StartReaper
/go/src/github.com/openshift/origin/pkg/util/proc/reaper.go:35 +0x79
goroutine 82 [select, 129 minutes, locked to thread]:
runtime.gopark(0x3e67cf8, 0xc820023f28, 0x3573d80, 0x6, 0x430218, 0x2)
/usr/local/go/src/runtime/proc.go:262 +0x163
runtime.selectgoImpl(0xc820023f28, 0x0, 0x18)
/usr/local/go/src/runtime/select.go:392 +0xa67
runtime.selectgo(0xc820023f28)
/usr/local/go/src/runtime/select.go:215 +0x12
runtime.ensureSigM.func1()
/usr/local/go/src/runtime/signal1_unix.go:279 +0x358
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1998 +0x1
goroutine 2218 [IO wait]:
net.runtime_pollWait(0x7f161f2cd258, 0x72, 0xc82046e800)
/usr/local/go/src/runtime/netpoll.go:160 +0x60
net.(*pollDesc).Wait(0xc8204c3f00, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a
net.(*pollDesc).WaitRead(0xc8204c3f00, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:78 +0x36
net.(*netFD).Read(0xc8204c3ea0, 0xc82046e800, 0x400, 0x400, 0x0, 0x7f161f2b4028, 0xc82005e080)
/usr/local/go/src/net/fd_unix.go:250 +0x23a
net.(*conn).Read(0xc820024288, 0xc82046e800, 0x400, 0x400, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:172 +0xe4
crypto/tls.(*block).readFromUntil(0xc8208aa360, 0x7f161f3005f8, 0xc820024288, 0x5, 0x0, 0x0)
/usr/local/go/src/crypto/tls/conn.go:460 +0xcc
crypto/tls.(*Conn).readRecord(0xc820676300, 0x3e67e17, 0x0, 0x0)
/usr/local/go/src/crypto/tls/conn.go:562 +0x2d1
crypto/tls.(*Conn).Read(0xc820676300, 0xc820840000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/crypto/tls/conn.go:939 +0x167
net/http.noteEOFReader.Read(0x7f161f3006b0, 0xc820676300, 0xc8207b1248, 0xc820840000, 0x1000, 0x1000, 0xc820027800, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1683 +0x67
net/http.(*noteEOFReader).Read(0xc8209f0380, 0xc820840000, 0x1000, 0x1000, 0xfc19b4, 0x0, 0x0)
<autogenerated>:284 +0xd0
bufio.(*Reader).fill(0xc820979e60)
/usr/local/go/src/bufio/bufio.go:97 +0x1e9
bufio.(*Reader).ReadSlice(0xc820979e60, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:328 +0x21a
net/http/internal.readChunkLine(0xc820979e60, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:110 +0x53
net/http/internal.(*chunkedReader).beginChunk(0xc8208aa3f0)
/usr/local/go/src/net/http/internal/chunked.go:47 +0x39
net/http/internal.(*chunkedReader).Read(0xc8208aa3f0, 0xc820151600, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:77 +0xb7
net/http.(*body).readLocked(0xc820860200, 0xc820151600, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:651 +0xa1
net/http.(*body).Read(0xc820860200, 0xc820151600, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:643 +0x110
net/http.(*bodyEOFSignal).Read(0xc820860280, 0xc820151600, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1609 +0x26a
encoding/json.(*Decoder).refill(0xc8203924e0, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:152 +0x287
encoding/json.(*Decoder).readValue(0xc8203924e0, 0x1, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:128 +0x413
encoding/json.(*Decoder).Decode(0xc8203924e0, 0x275c5c0, 0xc8208602c0, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:57 +0x159
k8s.io/kubernetes/pkg/watch/json.(*Decoder).Decode(0xc8208aa420, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/json/decoder.go:50 +0xa5
k8s.io/kubernetes/pkg/watch.(*StreamWatcher).receive(0xc8208aa450)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/iowatcher.go:93 +0x104
created by k8s.io/kubernetes/pkg/watch.NewStreamWatcher
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/iowatcher.go:60 +0xbf
goroutine 2243 [select]:
net/http.(*persistConn).readLoop(0xc820815ba0)
/usr/local/go/src/net/http/transport.go:1178 +0xd52
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:853 +0x10a6
goroutine 2244 [select]:
net/http.(*persistConn).writeLoop(0xc820815ba0)
/usr/local/go/src/net/http/transport.go:1273 +0x472
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:854 +0x10cb
goroutine 2220 [IO wait]:
net.runtime_pollWait(0x7f161f2cd198, 0x72, 0xc8209f6000)
/usr/local/go/src/runtime/netpoll.go:160 +0x60
net.(*pollDesc).Wait(0xc82054c4c0, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:73 +0x3a
net.(*pollDesc).WaitRead(0xc82054c4c0, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:78 +0x36
net.(*netFD).Read(0xc82054c460, 0xc8209f6000, 0x8000, 0x8000, 0x0, 0x7f161f2b4028, 0xc82005e080)
/usr/local/go/src/net/fd_unix.go:250 +0x23a
net.(*conn).Read(0xc8200242d8, 0xc8209f6000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:172 +0xe4
crypto/tls.(*block).readFromUntil(0xc820a35b00, 0x7f161f3005f8, 0xc8200242d8, 0x5, 0x0, 0x0)
/usr/local/go/src/crypto/tls/conn.go:460 +0xcc
crypto/tls.(*Conn).readRecord(0xc820676600, 0x3e67e17, 0x0, 0x0)
/usr/local/go/src/crypto/tls/conn.go:562 +0x2d1
crypto/tls.(*Conn).Read(0xc820676600, 0xc82072a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/crypto/tls/conn.go:939 +0x167
net/http.noteEOFReader.Read(0x7f161f3006b0, 0xc820676600, 0xc820815c08, 0xc82072a000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1683 +0x67
net/http.(*noteEOFReader).Read(0xc82059b9c0, 0xc82072a000, 0x1000, 0x1000, 0xc8208aa480, 0x0, 0x0)
<autogenerated>:284 +0xd0
bufio.(*Reader).fill(0xc8207fc3c0)
/usr/local/go/src/bufio/bufio.go:97 +0x1e9
bufio.(*Reader).ReadSlice(0xc8207fc3c0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:328 +0x21a
net/http/internal.readChunkLine(0xc8207fc3c0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:110 +0x53
net/http/internal.(*chunkedReader).beginChunk(0xc8208aab70)
/usr/local/go/src/net/http/internal/chunked.go:47 +0x39
net/http/internal.(*chunkedReader).Read(0xc8208aab70, 0xc820151c00, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:77 +0xb7
net/http.(*body).readLocked(0xc8208604c0, 0xc820151c00, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:651 +0xa1
net/http.(*body).Read(0xc8208604c0, 0xc820151c00, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:643 +0x110
net/http.(*bodyEOFSignal).Read(0xc820860500, 0xc820151c00, 0x200, 0x200, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1609 +0x26a
encoding/json.(*Decoder).refill(0xc820392680, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:152 +0x287
encoding/json.(*Decoder).readValue(0xc820392680, 0x1, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:128 +0x413
encoding/json.(*Decoder).Decode(0xc820392680, 0x275c5c0, 0xc820860540, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:57 +0x159
k8s.io/kubernetes/pkg/watch/json.(*Decoder).Decode(0xc8208aaba0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/json/decoder.go:50 +0xa5
k8s.io/kubernetes/pkg/watch.(*StreamWatcher).receive(0xc8208aabd0)
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/iowatcher.go:93 +0x104
created by k8s.io/kubernetes/pkg/watch.NewStreamWatcher
/go/src/github.com/openshift/origin/Godeps/_workspace/src/k8s.io/kubernetes/pkg/watch/iowatcher.go:60 +0xbf
goroutine 2238 [select]:
net/http.(*persistConn).writeLoop(0xc8207b11e0)
/usr/local/go/src/net/http/transport.go:1273 +0x472
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:854 +0x10cb
goroutine 2237 [select]:
net/http.(*persistConn).readLoop(0xc8207b11e0)
/usr/local/go/src/net/http/transport.go:1178 +0xd52
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:853 +0x10a6
Is this normal? Should we be concerned?
For anyone else getting this issue, I was able to track down this github issue where this is discussed (and a PR later submitted to fix): https://github.com/openshift/origin/issues/8825
Related
I'm thinking about doing a project using an NXP eval board with the RT 1020 processor. I want to experiment with and get familiar with Zephyr RTOS.
How, in code, would I access the various Arduino header PINS with the given Device Tree snippet?
arduino_header: connector {
compatible = "arduino-header-r3";
#gpio-cells = < 0x2 >;
gpio-map-mask = < 0xffffffff 0xffffffc0 >;
gpio-map-pass-thru = < 0x0 0x3f >;
gpio-map = < 0x0 0x0 &gpio1 0x1a 0x0 >, < 0x1 0x0 &gpio1 0x1b 0x0 >, < 0x2 0x0 &gpio1 0x1c 0x0 >, < 0x3 0x0 &gpio1 0x1d 0x0 >, < 0x4 0x0 &gpio1 0x1f 0x0 >, < 0x5 0x0 &gpio1 0x1e 0x0 >, < 0x6 0x0 &gpio1 0x19 0x0 >, < 0x7 0x0 &gpio1 0x18 0x0 >, < 0x8 0x0 &gpio1 0x9 0x0 >, < 0x9 0x0 &gpio1 0x7 0x0 >, < 0xa 0x0 &gpio1 0x5 0x0 >, < 0xb 0x0 &gpio1 0x6 0x0 >, < 0xc 0x0 &gpio1 0xe 0x0 >, < 0xd 0x0 &gpio1 0x16 0x0 >, < 0xe 0x0 &gpio1 0x17 0x0 >, < 0xf 0x0 &gpio1 0xf 0x0 >, < 0x10 0x0 &gpio1 0xb 0x0 >, < 0x11 0x0 &gpio1 0xc 0x0 >, < 0x12 0x0 &gpio1 0xd 0x0 >, < 0x13 0x0 &gpio1 0xa 0x0 >, < 0x14 0x0 &gpio3 0x17 0x0 >, < 0x15 0x0 &gpio3 0x16 0x0 >;
};
I know that I can use device_get_binding() and gpio_pin_configure() with DT_GPIO_LABEL and DT_GPIO_PIN easily enough with a single pin that has a device tree alias.
I'm not clear how I'd access the Arduino header pins from the device tree snippet above.
I am trying to inflate an object stream in a pdf. While inflating one of the object stream which is compressed with flate decode I am getting data error.
Object stream
1339 0 obj^M<</First 7/Length 36/Filter/FlateDecode/N 1/Type/ObjStm>>stream^M
^ZÖ¬Áã9^<87>^GÎ<89><93>^WÊ<8d>ð<93>yM<96>t0Ò=$Ô<·×^L<84>°¯$<8b>^M
endstream
**Encryption object **
1698 0 obj^M<</Length 128/Filter/Standard/O(¡"ÎÙ¢¬<9d><9c>"\r^S^LÀõeâJý;Î{dTÔÜ<9d>~´>^Tº)/P -1324/R 3/U(É^[®ú^F^C /¬®=ÌæZv5');\r\n view( a)/V 2>>^Mendobj
After decrypting I got this data
{0x68, 0x16, 0x48, 0x59, 0x11, 0xef, 0x34, 0xe9, 0xd0, 0x79, 0xf6, 0xcb, 0x73, 0xf6, 0x8a, 0x50, 0xed, 0xdc, 0x34, 0xe9, 0x60, 0xb1, 0xbf, 0x3, 0xf5, 0x92, 0x5, 0x67, 0x60, 0xd9, 0x84, 0x34, 0x44, 0xad, 0xa9, 0x5c}
Now I have to uncompress this data.
I am getting data error after calling inflate(&zstrm, Z_FINISH);
I am stuck here. Can anyone please help me to understand this error.
Ans :
Here the input I was supplying to zlib was not a valid inflate data. When the input stream was encrypted the first character was new line character. I was skipping that newline character. That was the error.
That's not a zlib stream, nor is it even raw deflate data.
I simply want to send from device to host with two report ID.These reports must have different Report Count(First report id has 4 report count, second report id has 40).This is what I have done so far:
//14 bytes
0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1)
0x09, 0x01, // USAGE (Vendor Usage 1)
0xa1, 0x01, // COLLECTION (Application)
// -------- common global items ---------
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
// 10 bytes | Input message 1 (sent from device to host)
0x85, 5, // Global Report ID (cannot be 0)
0x95, 4, // Global Report Count (number of Report Size fields)
0x19, 0x01, // USAGE_MINIMUM (Vendor Usage 1)
0x29, 5, // USAGE_MAXIMUM (Vendor Usage 64)
0x81, 0x02, // Main Input (data, array, absolute)
// 10 bytes | Input message 1 (sent from device to host)
0x85, 6, // Global Report ID (cannot be 0)
0x95, 40, // Global Report Count (number of Report Size fields)
0x19, 0x01, // USAGE_MINIMUM (Vendor Usage 1)
0x29, 41, // USAGE_MAXIMUM (Vendor Usage 64)
0x81, 0x02, // Main Input (data, array, absolute)
0xC0
But first report id is sending 40 bayt.Where is my mistake?
HID Terminal output:
R 02 0C 16 20 2A 34 3E 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
R 01 0B 15 1F 29 34 3E 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
I believe #Nipo has given you the correct answer: the report descriptor indicates what each report should look like, but it is still the responsibility of your code to send reports with the correct length specified.
For report id 5 that would be 5 (1 for the report id + 4 for the payload), and
for report it 6 it would be 41 (1 for the report id + 40 for the payload).
BTW, your report descriptor may need a little tweaking. As it stands, it decodes as:
//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------
PROGMEM char usbHidReportDescriptor[] =
{
0x06, 0x00, 0xFF, // (GLOBAL) USAGE_PAGE 0xFF00 Vendor-defined
0x09, 0x01, // (LOCAL) USAGE 0xFF000001 <-- Warning: Undocumented usage
0xA1, 0x01, // (MAIN) COLLECTION 0x00000001 Application (Usage=0xFF000001: Page=Vendor-defined, Usage=, Type=)
0x15, 0x00, // (GLOBAL) LOGICAL_MINIMUM 0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0 <-- Info: Consider replacing 15 00 with 14
0x26, 0xFF, 0x00, // (GLOBAL) LOGICAL_MAXIMUM 0x00FF (255)
0x75, 0x08, // (GLOBAL) REPORT_SIZE 0x08 (8) Number of bits per field
0x85, 0x05, // (GLOBAL) REPORT_ID 0x05 (5)
0x95, 0x04, // (GLOBAL) REPORT_COUNT 0x04 (4) Number of fields
0x19, 0x01, // (LOCAL) USAGE_MINIMUM 0xFF000001 <-- Warning: Undocumented usage
0x29, 0x05, // (LOCAL) USAGE_MAXIMUM 0xFF000005 <-- Warning: Undocumented usage
0x81, 0x02, // (MAIN) INPUT 0x00000002 (4 fields x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap
0x85, 0x06, // (GLOBAL) REPORT_ID 0x06 (6)
0x95, 0x28, // (GLOBAL) REPORT_COUNT 0x28 (40) Number of fields
0x19, 0x01, // (LOCAL) USAGE_MINIMUM 0xFF000001 <-- Warning: Undocumented usage
0x29, 0x29, // (LOCAL) USAGE_MAXIMUM 0xFF000029 <-- Warning: Undocumented usage
0x81, 0x02, // (MAIN) INPUT 0x00000002 (40 fields x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap
0xC0, // (MAIN) END_COLLECTION Application
};
//--------------------------------------------------------------------------------
// Vendor-defined inputReport 05 (Device --> Host)
//--------------------------------------------------------------------------------
typedef struct
{
uint8_t reportId; // Report ID = 0x05 (5)
uint8_t VEN_VendorDefined0001; // Usage 0xFF000001: , Value = 0 to 255
uint8_t VEN_VendorDefined0002; // Usage 0xFF000002: , Value = 0 to 255
uint8_t VEN_VendorDefined0003; // Usage 0xFF000003: , Value = 0 to 255
uint8_t VEN_VendorDefined0004; // Usage 0xFF000004: , Value = 0 to 255
// Usage 0xFF000005 Value = 0 to 255 <-- Ignored: REPORT_COUNT (4) is too small
} inputReport05_t;
//--------------------------------------------------------------------------------
// Vendor-defined inputReport 06 (Device --> Host)
//--------------------------------------------------------------------------------
typedef struct
{
uint8_t reportId; // Report ID = 0x06 (6)
uint8_t VEN_VendorDefined0001; // Usage 0xFF000001: , Value = 0 to 255
uint8_t VEN_VendorDefined0002; // Usage 0xFF000002: , Value = 0 to 255
uint8_t VEN_VendorDefined0003; // Usage 0xFF000003: , Value = 0 to 255
uint8_t VEN_VendorDefined0004; // Usage 0xFF000004: , Value = 0 to 255
uint8_t VEN_VendorDefined0005; // Usage 0xFF000005: , Value = 0 to 255
uint8_t VEN_VendorDefined0006; // Usage 0xFF000006: , Value = 0 to 255
uint8_t VEN_VendorDefined0007; // Usage 0xFF000007: , Value = 0 to 255
uint8_t VEN_VendorDefined0008; // Usage 0xFF000008: , Value = 0 to 255
uint8_t VEN_VendorDefined0009; // Usage 0xFF000009: , Value = 0 to 255
uint8_t VEN_VendorDefined000A; // Usage 0xFF00000A: , Value = 0 to 255
uint8_t VEN_VendorDefined000B; // Usage 0xFF00000B: , Value = 0 to 255
uint8_t VEN_VendorDefined000C; // Usage 0xFF00000C: , Value = 0 to 255
uint8_t VEN_VendorDefined000D; // Usage 0xFF00000D: , Value = 0 to 255
uint8_t VEN_VendorDefined000E; // Usage 0xFF00000E: , Value = 0 to 255
uint8_t VEN_VendorDefined000F; // Usage 0xFF00000F: , Value = 0 to 255
uint8_t VEN_VendorDefined0010; // Usage 0xFF000010: , Value = 0 to 255
uint8_t VEN_VendorDefined0011; // Usage 0xFF000011: , Value = 0 to 255
uint8_t VEN_VendorDefined0012; // Usage 0xFF000012: , Value = 0 to 255
uint8_t VEN_VendorDefined0013; // Usage 0xFF000013: , Value = 0 to 255
uint8_t VEN_VendorDefined0014; // Usage 0xFF000014: , Value = 0 to 255
uint8_t VEN_VendorDefined0015; // Usage 0xFF000015: , Value = 0 to 255
uint8_t VEN_VendorDefined0016; // Usage 0xFF000016: , Value = 0 to 255
uint8_t VEN_VendorDefined0017; // Usage 0xFF000017: , Value = 0 to 255
uint8_t VEN_VendorDefined0018; // Usage 0xFF000018: , Value = 0 to 255
uint8_t VEN_VendorDefined0019; // Usage 0xFF000019: , Value = 0 to 255
uint8_t VEN_VendorDefined001A; // Usage 0xFF00001A: , Value = 0 to 255
uint8_t VEN_VendorDefined001B; // Usage 0xFF00001B: , Value = 0 to 255
uint8_t VEN_VendorDefined001C; // Usage 0xFF00001C: , Value = 0 to 255
uint8_t VEN_VendorDefined001D; // Usage 0xFF00001D: , Value = 0 to 255
uint8_t VEN_VendorDefined001E; // Usage 0xFF00001E: , Value = 0 to 255
uint8_t VEN_VendorDefined001F; // Usage 0xFF00001F: , Value = 0 to 255
uint8_t VEN_VendorDefined0020; // Usage 0xFF000020: , Value = 0 to 255
uint8_t VEN_VendorDefined0021; // Usage 0xFF000021: , Value = 0 to 255
uint8_t VEN_VendorDefined0022; // Usage 0xFF000022: , Value = 0 to 255
uint8_t VEN_VendorDefined0023; // Usage 0xFF000023: , Value = 0 to 255
uint8_t VEN_VendorDefined0024; // Usage 0xFF000024: , Value = 0 to 255
uint8_t VEN_VendorDefined0025; // Usage 0xFF000025: , Value = 0 to 255
uint8_t VEN_VendorDefined0026; // Usage 0xFF000026: , Value = 0 to 255
uint8_t VEN_VendorDefined0027; // Usage 0xFF000027: , Value = 0 to 255
uint8_t VEN_VendorDefined0028; // Usage 0xFF000028: , Value = 0 to 255
// Usage 0xFF000029 Value = 0 to 255 <-- Ignored: REPORT_COUNT (40) is too small
} inputReport06_t;
You may want to try the following instead:
//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------
PROGMEM char usbHidReportDescriptor[] =
{
0x06, 0x00, 0xFF, // (GLOBAL) USAGE_PAGE 0xFF00 Vendor-defined
0x09, 0x01, // (LOCAL) USAGE 0xFF000001 <-- Warning: Undocumented usage
0xA1, 0x01, // (MAIN) COLLECTION 0x00000001 Application (Usage=0xFF000001: Page=Vendor-defined, Usage=, Type=)
0x15, 0x00, // (GLOBAL) LOGICAL_MINIMUM 0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0 <-- Info: Consider replacing 15 00 with 14
0x26, 0xFF, 0x00, // (GLOBAL) LOGICAL_MAXIMUM 0x00FF (255)
0x75, 0x08, // (GLOBAL) REPORT_SIZE 0x08 (8) Number of bits per field
0x85, 0x05, // (GLOBAL) REPORT_ID 0x05 (5)
0x95, 0x04, // (GLOBAL) REPORT_COUNT 0x04 (4) Number of fields
0x19, 0x01, // (LOCAL) USAGE_MINIMUM 0xFF000001 <-- Warning: Undocumented usage
0x29, 0x04, // (LOCAL) USAGE_MAXIMUM 0xFF000004 <-- Warning: Undocumented usage
0x81, 0x00, // (MAIN) INPUT 0x00000000 (4 fields x 8 bits) 0=Data 0=Array 0=Absolute 0=Ignored 0=Ignored 0=PrefState 0=NoNull
0x85, 0x06, // (GLOBAL) REPORT_ID 0x06 (6)
0x95, 0x28, // (GLOBAL) REPORT_COUNT 0x28 (40) Number of fields
0x19, 0x01, // (LOCAL) USAGE_MINIMUM 0xFF000001 <-- Warning: Undocumented usage
0x29, 0x28, // (LOCAL) USAGE_MAXIMUM 0xFF000028 <-- Warning: Undocumented usage
0x81, 0x00, // (MAIN) INPUT 0x00000000 (40 fields x 8 bits) 0=Data 0=Array 0=Absolute 0=Ignored 0=Ignored 0=PrefState 0=NoNull
0xC0, // (MAIN) END_COLLECTION Application
};
//--------------------------------------------------------------------------------
// Vendor-defined inputReport 05 (Device --> Host)
//--------------------------------------------------------------------------------
typedef struct
{
uint8_t reportId; // Report ID = 0x05 (5)
uint8_t VEN_VendorDefined[4]; // Value = 0 to 255
} inputReport05_t;
//--------------------------------------------------------------------------------
// Vendor-defined inputReport 06 (Device --> Host)
//--------------------------------------------------------------------------------
typedef struct
{
uint8_t reportId; // Report ID = 0x06 (6)
uint8_t VEN_VendorDefined[40]; // Value = 0 to 255
} inputReport06_t;
Some C++ application compiled and run seamlessly in OS X Snow Leopard, but I changed recently to OS X Lion, and here, although there is no compilation error, when I try to run it I get the error "Illegal instruction: 4", I have no clue, what could be the reason?
PS:
These are the linking flags I use
-Wl,-stack_size,0x10000000,-stack_addr,0xc0000000
This is the output I get when I do sudo truss executable
setrlimit returned result = -1
SYSCALL(args) = return
getpid(0x0, 0x0, 0x0) = 32993 0
__sysctl(0xBFFFF5EC, 0x3, 0xBFFFF5E8) = 0 0
issetugid(0xBFFFF5EC, 0x3, 0xBFFFF5E8) = 0 0
csops(0x0, 0x0, 0xBFFFF65C) = 0 0
shared_region_check_np(0xBFFFD5E0, 0x0, 0xBFFFF65C) = 0 0
stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0xBFFFE830, 0xBFFFF65C) = 0 0
open("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x0, 0x0) = 3 0
pread(0x3, "\312\376\272\276\0", 0x1000, 0x0) = 4096 0
pread(0x3, "\316\372\355\376\a\0", 0x1000, 0x6000) = 4096 0
mmap(0x4D3000, 0x2000, 0x1, 0x12, 0x3, 0x3) = 0x4D3000 0
mmap(0x4D5000, 0x1000, 0x3, 0x12, 0x3, 0x3) = 0x4D5000 0
mmap(0x4D6000, 0x1EF0, 0x1, 0x12, 0x3, 0x3) = 0x4D6000 0
close(0x3) = 0 0
stat64("/usr/lib/libstdc++.6.dylib\0", 0xBFFFE690, 0x1) = 0 0
stat64("/usr/lib/libgcc_s.1.dylib\0", 0xBFFFE690, 0x1) = 0 0
stat64("/usr/lib/libSystem.B.dylib\0", 0xBFFFE560, 0x1) = 0 0
stat64("/usr/lib/libc++abi.dylib\0", 0xBFFFE5D0, 0x1) = 0 0
stat64("/usr/lib/system/libcache.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libcommonCrypto.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libcompiler_rt.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libcopyfile.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libdispatch.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libdnsinfo.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libdyld.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libkeymgr.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/liblaunch.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libmacho.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libmathCommon.A.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libquarantine.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libremovefile.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_blocks.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_c.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_dnssd.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_info.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_kernel.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_network.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_notify.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libsystem_sandbox.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libunc.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libunwind.dylib\0", 0xBFFFE360, 0x1) = 0 0
stat64("/usr/lib/system/libxpc.dylib\0", 0xBFFFE360, 0x1) = 0 0
open("/dev/dtracehelper\0", 0x2, 0xBFFFF5B0) = 3 0
ioctl(0x3, 0x80086804, 0xBFFFF540) = 0 0
close(0x3) = 0 0
__sysctl(0xBFFFF1FC, 0x2, 0xBFFFF1F4) = 0 0
bsdthread_register(0x92C9F6BC, 0x92C9F6E0, 0x1000) = 0 0
thread_selfid(0x92C9F6BC, 0x92C9F6E0, 0x1000) = 2500945 0
mmap(0x0, 0x2000, 0x3, 0x1002, 0x1000000, 0xAC308375) = 0x4D8000 0
mprotect(0x4D8000, 0x44, 0x1) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x4D8034) = 0x4DA000 0
mprotect(0x4DA000, 0x1000, 0x0) = 0 0
mprotect(0x4E6000, 0x1000, 0x0) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x4DB000) = 0x4E7000 0
mprotect(0x4E7000, 0x1000, 0x0) = 0 0
mprotect(0x4F3000, 0x1000, 0x0) = 0 0
mmap(0x0, 0x1000, 0x3, 0x1002, 0x1000000, 0x4E8000) = 0x4F4000 0
mprotect(0x4F4000, 0x1000, 0x1) = 0 0
mprotect(0x4D8000, 0x44, 0x3) = 0 0
mmap(0x0, 0x200000, 0x3, 0x1002, 0x7000000, 0x4F4000) = 0x4F5000 0
munmap(0x4F5000, 0xB000) = 0 0
munmap(0x600000, 0xF5000) = 0 0
mprotect(0x4D8000, 0x44, 0x1) = 0 0
getpid(0x4D8000, 0x44, 0x1) = 32993 0
__mac_syscall(0x973E8E8E, 0x2, 0xBFFFF0C8) = 0 0
stat64("/AppleInternal\0", 0xBFFFF130, 0xBFFFF0C8) = -1 Err#2
audit_session_self(0x92C1F4B6, 0xBFFFF130, 0xBFFFF0C8) = 5635 0
geteuid(0x92C1F4B6, 0xBFFFF130, 0xBFFFF0C8) = 0 0
getegid(0x92C1F4B6, 0xBFFFF130, 0xBFFFF0C8) = 0 0
getaudit_addr(0xBFFFF0A8, 0x30, 0xBFFFF0C8) = 0 0
csops(0x80E1, 0x7, 0xBFFFECF8) = 0 0
mmap(0x0, 0x2000, 0x3, 0x1002, 0x1000000, 0xACA5EB00) = 0x4F5000 0
mprotect(0x4F5000, 0x44, 0x1) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x4F5034) = 0x600000 0
mprotect(0x600000, 0x1000, 0x0) = 0 0
mprotect(0x60C000, 0x1000, 0x0) = 0 0
mmap(0x0, 0xD000, 0x3, 0x1002, 0x1000000, 0x601000) = 0x60D000 0
mprotect(0x60D000, 0x1000, 0x0) = 0 0
mprotect(0x619000, 0x1000, 0x0) = 0 0
mprotect(0x4F4000, 0x1000, 0x3) = 0 0
mprotect(0x4F4000, 0x1000, 0x1) = 0 0
mprotect(0x4F5000, 0x44, 0x3) = 0 0
mmap(0x0, 0x200000, 0x3, 0x1002, 0x7000000, 0x4F4004) = 0x61A000 0
munmap(0x61A000, 0xE6000) = 0 0
munmap(0x800000, 0x1A000) = 0 0
mprotect(0x4F5000, 0x44, 0x1) = 0 0
getrlimit(0x1003, 0xBFFFF8DC, 0x1) = 0 0
setrlimit(0x1003, 0xBFFFF8DC, 0x1) = -1 Err#22
getrlimit(0x1008, 0xBF835C60, 0x1) = 0 0
fstat64(0x1, 0xBF836090, 0x1F) = 0 0
mmap(0x0, 0x1000000, 0x3, 0x1002, 0x2000000, 0xACA5B3E0) = 0x800000 0
munmap(0x1000000, 0x800000) = 0 0
PS2: If I remove the previously mentioned linking flag, the program runs, with no error. But when I input real data to the program, then I get
Segmentation fault: 11
I remember that this program had a problem with the stack, so it had to be increased. In Linux I did this and works
const rlim_t kStackSize = 256L * 1024L * 1024L; // min stack size = 64 Mb
struct rlimit rl;
int result;
result = getrlimit(RLIMIT_STACK, &rl);
if (result == 0)
{
if (rl.rlim_cur < kStackSize)
{
rl.rlim_cur = kStackSize;
result = setrlimit(RLIMIT_STACK, &rl);
if (result != 0)
{
fprintf(stderr, "setrlimit returned result = %d\n", result);
}
}
}
but in OS X, since that did not work, I used the previously mentioned linking flag, and had no problem is OS X Snow Leopard, so it seems I still have the stack overflow problem in OS X Lion but the linking flag does not solve this. What could I do?
I encountered this issue when building a product on Mountain Lion (10.8,) and then running on Lion. (10.7). The cause was that I made some changes to my build environment.
(I'm using mkbundle to ship a product that uses Mono.)
The fix was very simple, I had to tell clang that generated binaries need to work on OSX 10.6. I added the following argument to clang:
-mmacosx-version-min=10.6
Problem solved!
In OS X Lion (but also 10.5) the stack size hard limit is 65532 kbytes (just under 64 MiB).
This can be seen with:
bswift$ ulimit -Hs
65532
Even as root, I couldn't increase this value.
The soft limit defaults to only 8 MiB:
bswift$ ulimit -Ss
8192
Try raising the value to this maximum before starting you application:
bswift$ ulimit -Ss unlimited
bswift$ ulimit -Ss
65532
Note: segmentation fault (SIGSEGV) (number 11) you observed is the signal sent to the process when the stack limit is exceeded according to man setrlimit
Note: Since the ulimit command needs to be a shell builtin, you will find it documented in man bash
This could be a permissions issue.
To diagnose further, run your program from the terminal with sudo dtruss prefixed. See which syscall it runs before throwing the error.
Example: sudo dtruss /path/to/application
You can also diagnose it with the Xcode or GDB debuggers.
I've stumbled across a problem way beyond my area of expertise, and I don't have a mentor to turn to for help with this.
I have a receipt printer I need to interface with through an iOS app. The printer is located on the same network as the device(s), so I can address it through supported "Line Mode commands"
What I'd like to do is keep the code I have already that works cross-platform – i.e. it's a UIView/NSView, and if you're not familiar with OS X/iOS, it's just a standard vanilla view that I can render into PDF/PNG formats. Thankfully, the printer has a "raster graphics" mode that seems to be what I need.
Unfortunately, be it the broken English of the command spec, or my complete lack of knowledge of anything beyond basic C, or my complete lack of knowledge regarding graphics, I have no idea how to even get started from the command specifications I have. I know the printer and my networking works because I can address it over the network and send it basic feed commands. But, I have no idea how to go from a PNG -> whatever the printer needs to make it's 'raster mode' work.
The specification is available at http://www.star-m.jp/eng/service/usermanual/linemode_cm_en.pdf , and the page you'd want to start reading it if you want to help is 3-68, and the specific commands I'm having trouble even getting started with are on 3-78/3-79.
I can give you nothing but a checkmark but I assure you, you'll have my undying gratitude if you can even provide me even a point in the right direction.
Having written a few printer drivers I can confirm that generally the documentation is confusing because of the way printers work. The document that you refer to doesn't actually seem to bad to me.
I think you're right to be printing in raster mode and that overall this is going to give the best results.
From the Star documentation I reckon you'll need to send :
1. \x1b*rR Initialize raster mode
2. \x1b*rA Enter raster mode
3. \x1b*rC Clear raster data
4. \x1b*rml
4. b\x##\x##\xAA\xAA\xAA....<DATA>..........
5. \x1b\x0C\x00 Raster Form feed(??) - should spit out the data.
6. \x1b*rB Clear raster data
Obv. in the above \x1b is the C encoding of ESC (i.e. character 27 0x1b).
From all of the documentation that I've been reading the following is how the images should be formatted in raster mode. When in line mode it is completely different as the vertical & horizontal are swapped. From THERMAL PRINTER PROGRAMMER'S MANUAL (TSP552,TSP552II,TSP2000)
This equates to the following bytes stream.
On the 4th command line it is effectively 'b' followed by two bytes definining the size. This size is computed as the number of pixels contained in the stream % 256 and / 256. So for 320x1 that'd 0x40,0x01
So, taking the above and plugging it into a simple test program you should test with this:
char rasterImage [] = {
0x1b, '*', 'r', 'R', // Initialize raster mode
0x1b, '*', 'r', 'A', // Enter raster mode
0x1b, '*', 'r', 'C', // Clear raster data
// n1 n2 d1 d2..
0x1b, 'b', 0x2, 0, 0x00, 0x00, // data
0x1b, 'b', 0x2, 0, 0x1F, 0xF8,
0x1b, 'b', 0x2, 0, 0x3F, 0xFC,
0x1b, 'b', 0x2, 0, 0x77, 0xEE,
0x1b, 'b', 0x2, 0, 0xF8, 0x1F,
0x1b, 'b', 0x2, 0, 0xF8, 0x1F,
0x1b, 'b', 0x2, 0, 0xF8, 0x1F,
0x1b, 'b', 0x2, 0, 0x0F, 0xF0,
0x1b, 'b', 0x2, 0, 0x1F, 0xF8,
0x1b, 'b', 0x2, 0, 0x1F, 0xF8,
0x1b, 'b', 0x2, 0, 0x3E, 0x7C,
0x1b, 'b', 0x2, 0, 0x38, 0x1C,
0x1b, 'b', 0x2, 0, 0x79, 0x9E,
0x1b, 'b', 0x2, 0, 0x73, 0xCE,
0x1b, 'b', 0x2, 0, 0x73, 0xCE,
0x1b, 'b', 0x2, 0, 0xF9, 0x9F,
0x1b, 'b', 0x2, 0, 0xF8, 0x1F,
0x1b, 'b', 0x2, 0, 0xFE, 0x7F,
0x1b, 'b', 0x2, 0, 0xFF, 0xFF,
0x1b, 'b', 0x2, 0, 0xFF, 0xFF,
0x1b, 'b', 0x2, 0, 0x00, 0x00,
0x1b, 'b', 0x2, 0, 0x00, 0x00,
0x1b, 'b', 0x2, 0, 0x00, 0x00,
0x1b, 'b', 0x2, 0, 0x00, 0x00};
[self.currentDataBeingSent appendBytes:rasterImage length:sizeof(rasterImage)];
Simply squirt that out to the printer and you should get a picture as above. This is where you can easily tweak and play about with the exact commands to get something that's working. Often this is the only way I've ever managed to figure out what should be done.
rev.3
Ref. comments.
If you have a byte per pixel then you will need to merge these into a series of bits; the following should do the job based on your pastebin code. I've also changed the char* to be unsigned as it is signed can cause problems when bit manipulating.
NSUInteger bitmapBytePerRow = width/8;
NSUInteger bytesPerRow = 3 + bitmapBytePerRow;
[self.currentDataBeingSent = [NSMutableData dataWithLength:bytesPerRow * height];
[self.currentDataBeingSent appendBytes:initializeRaster length:sizeof(initializeRaster)];
[self.currentDataBeingSent appendBytes:enterRaster length:sizeof(enterRaster)];
NSUInteger byteOffset = 0;
for (NSUInteger y = 0; y < height; y++)
{
unsigned char *rasterCommandForRow = (unsigned char *)calloc(bytesPerRow, sizeof(char));
unsigned char *current_raster = rasterCommandForRow;
*current_raster++ = '\x6B';
*current_raster++ = (width*height) % 256;
*current_raster++ = (width*height) / 256;
unsigned char mask = '\x80' ;
unsigned char out = 0 ;
for (NSUInteger x = 0; x < width; x++)
{
if (*(data + (byteOffset * sizeof(char))))
out |= mask ;
byteOffset++;
mask >>= 1 ;
if( 0 == mask )
{
mask = '\x80' ;
*current_raster++ = out ;
if( out )
lastDot = nextOut ;
out = 0 ;
}
}
// handle partially finished byte .
if( ( '\x80' != mask ) && ( 0 != out ) )
*current_raster++ = out ;
[self.currentDataBeingSent appendBytes:rasterCommandForRow length:bytesPerRow];
}
rev.3a
Looking at the Mac CUPS support from Star it's got the source code for the driver which contains a lot of clues about how this should be done. Sometimes code is so much easier to read than documentation.
starcupsdrv-3.1.1_mac_20100423.zip\starcupsdrv-3.1.1_mac\SourceCode\
contains starcupsdrv-src-3.1.1.tar.gz\ sub folder starcupsdrv\src\
View rastertostar.c, the important bit is the calculation of the n1 / n2 values. These aren't at all X & Y but based on the pixel count, lastBlackPixel is the count of pixels from the source.
putchar('b');
putchar((char) ((lastBlackPixel > 0)?(lastBlackPixel % 256):1));
putchar((char) (lastBlackPixel / 256));
I've modified the code above to include the fixes, hopefully that'll be closer. If not post a scan of what comes out of the printer, it will be useful to diagnose what's happening.
For reference The code between 580:650 from jsStarUSB.cpp seems to me to be along the lines of what you need to produce a buffer (stored in nextOut) that contains the raster data in the format to be sent directly to the printer.
rev. 4 (2023)
Joshua May advises in the comments that rasterImage doesn't need the ESC (0x1b) on each row - only the 'b' and that by just removing the 0x1b "worked for me".
I have a hunch this might be the same as the old Seiko printers, only yours is network enabled. If so, have a look at the C code here. It tries to output to a serial port /dev/cua, where it thinks the printer is.
But if the commands are the same, the code should help you. It takes as input the Portable Bitmap Format, which is plain ASCII text.
But I don't know. Microsoft indicates Star Micronics works the same as Epson LQ, in which case there is ample documentation.
Related links:
ESC/POS PDF Documentation, hundreds of pages
Command codes from the STAR website
Update! ;-) Try this, totally untested code:
/* Call with grayscale images of height 256, width 256. */
- (void) outputraster(char* pixels, int rows)
{
const char initializeRaster[] = "\x1B\x2A\x72\x52";
const char enterRaster[] = "\x1B\x2A\x72\x41";
const char formFeed[] = "\x1B\x0C\x00";
const char clearRaster[] = "\x1B\x2A\x72\x43";
const char exitRaster[] = "\x1B\x2A\x72\x42";
/* The FF means 255 lines: */
char setRasterPageLength[] "\x1B\x2A\x72\x50\xFF\x0";
/* The FF FF means 256 lines and 256 rows: */
char sendRasterData[] = "\x62\xFF\xFF";
[self sendBytes:initializeRaster ofLength:sizeof(initializeRaster)];
[self sendBytes:enterRaster ofLength:sizeof(enterRaster)];
[self sendBytes:clearRaster ofLength:sizeof(clearRaster)];
[self sendBytes:setRasterPageLength ofLength:sizeof(setRasterPageLength)];
[self sendBytes:sendRasterData ofLength:sizeof(sendRasterData)];
while (rows)
{
for (int x = 0; x < 255; x++)
{
[self sendBytes:pixels[x] ofLength:256];
}
rows --;
}
}
Update!
I was looking at the docs at night, and stumbled upon how you can print out a prestored logo. Then I looked at how to define that logo, and that part of the documentation looked a lot more thorough:
Explanations of bitmap format for a similar printer:
Also, look at pages 34 and on for an explanation of the bitmap format of a Star printer.
I hope this helps someone, but I was trying to use the code from Richard Harrison above to print the phone raster in Python...
I on my system I can run python3 raster.py > /dev/usb/lp0 and I get the expected output!! Hopefully it shows what you need. I cross refrenced the bytes of a file that would print, and also the graphical mode manual.
import sys
buf = [
0x1b, ord('*'), ord('r'), ord('A'), # enter raster mode
0x1b, ord('*'), ord('r'), ord('P'), ord('0'), 0x00, # continuous mode
ord('b'), 0x2, 0, 0x00, 0x00,
ord('b'), 0x2, 0, 0x1F, 0xF8,
ord('b'), 0x2, 0, 0x3F, 0xFC,
ord('b'), 0x2, 0, 0x77, 0xEE,
ord('b'), 0x2, 0, 0xF8, 0x1F,
ord('b'), 0x2, 0, 0xF8, 0x1F,
ord('b'), 0x2, 0, 0xF8, 0x1F,
ord('b'), 0x2, 0, 0x0F, 0xF0,
ord('b'), 0x2, 0, 0x1F, 0xF8,
ord('b'), 0x2, 0, 0x1F, 0xF8,
ord('b'), 0x2, 0, 0x3E, 0x7C,
ord('b'), 0x2, 0, 0x38, 0x1C,
ord('b'), 0x2, 0, 0x79, 0x9E,
ord('b'), 0x2, 0, 0x73, 0xCE,
ord('b'), 0x2, 0, 0x73, 0xCE,
ord('b'), 0x2, 0, 0xF9, 0x9F,
ord('b'), 0x2, 0, 0xF8, 0x1F,
ord('b'), 0x2, 0, 0xFE, 0x7F,
ord('b'), 0x2, 0, 0xFF, 0xFF,
ord('b'), 0x2, 0, 0xFF, 0xFF,
ord('b'), 0x2, 0, 0x00, 0x00,
ord('b'), 0x2, 0, 0x00, 0x00,
ord('b'), 0x2, 0, 0x00, 0x00,
ord('b'), 0x2, 0, 0x00, 0x00,
0x1b, ord('*'), ord('r'), ord('b') # end raster mode
]
blob = bytearray(buf)
sys.stdout.buffer.write(blob)
EDIT: Off the back of this, I created a Python library that will take an image and convert it into the required raster commands... https://pypi.org/project/StarTSPImage/