All,

I just wrote up a quick tutorial on how to enable newtmgr for an app. Thought 
it might be useful for developers that want to add newtmgr functionality to 
their project.

In the course of doing that (and debugging the shell prompt and it's 
interaction with newtmgr, I came across a great way to make newtmgr panic and 
crash. :-)

DSimmons-Pro:console_test dsimmons$ newtmgr -c myconn stat
panic: runtime error: index out of range

goroutine 1 [running]:
mynewt.apache.org/newt/newtmgr/cli.statsRunCmd(0xc8200d3800, 0xc82000e800, 0x0, 
0x2)
        
/Users/dsimmons/dev/go/src/mynewt.apache.org/newt/newtmgr/cli/stats.go:57 +0x950
github.com/spf13/cobra.(*Command).execute(0xc8200d3800, 0xc82000e600, 0x2, 0x2, 
0x0, 0x0)
        /Users/dsimmons/dev/go/src/github.com/spf13/cobra/command.go:565 +0x869
github.com/spf13/cobra.(*Command).ExecuteC(0xc8200d2000, 0xc8200d3800, 0x0, 0x0)
        /Users/dsimmons/dev/go/src/github.com/spf13/cobra/command.go:651 +0x56b
github.com/spf13/cobra.(*Command).Execute(0xc8200d2000, 0x0, 0x0)
        /Users/dsimmons/dev/go/src/github.com/spf13/cobra/command.go:610 +0x2d
main.main()
        /Users/dsimmons/dev/go/src/mynewt.apache.org/newt/newtmgr/newtmgr.go:25 
+0x25

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/Cellar/go/1.5.3/libexec/src/runtime/asm_amd64.s:1721 +0x1

goroutine 5 [syscall]:
os/signal.loop()
        /usr/local/Cellar/go/1.5.3/libexec/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
        /usr/local/Cellar/go/1.5.3/libexec/src/os/signal/signal_unix.go:28 +0x37
DSimmons-Pro:console_test dsimmons$

Seems the stat command requires an argument of which stat to show. If you don't 
know this, or forget to add it, or just want to make newtmgr crash, and you 
forget to add the required argument, *poof*! I'd fix it myself, but I really 
don't know go, and I'd hate to break newtmgr further. However, the bug is right 
here on line 57:


        srr.Name = args[0]

I believe a if !args[0] is required ...

Best regards,
dg
--
David G. Simmons
(919) 534-5099
Web <https://davidgs.com/> • Blog <https://davidgs.com/davidgs_blog> • Linkedin 
<http://linkedin.com/in/davidgsimmons> • Twitter 
<http://twitter.com/TechEvangelist1> • GitHub <http://github.com/davidgs>
/** Message digitally signed for security and authenticity.
* If you cannot read the PGP.sig attachment, please go to
 * http://www.gnupg.com/ <http://www.gnupg.com/> Secure your email!!!
 * Public key available at keyserver.pgp.com <http://keyserver.pgp.com/>
**/
♺ This email uses 100% recycled electrons. Don't blow it by printing!

There are only 2 hard things in computer science: Cache invalidation, naming 
things, and off-by-one errors.


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to