using ssh / segmentation fault

36 views
Skip to first unread message

David Mandelberg

unread,
Oct 11, 2013, 6:32:09 PM10/11/13
to rtr...@googlegroups.com
Hi,

I tried connecting to my server using ssh, but I just get a help
message. Am I doing something wrong? Also, what does "rtr-ssh"
represent?

$ /home/dmandelb/opt/rtrlib/bin/rtrclient ssh rtr-test.bbn.com rtr-ssh
~/.ssh/id_rsa ~/.ssh/id_rsa.pub
Usage:
/home/dmandelb/opt/rtrlib/bin/rtrclient tcp <host> <port>
/home/dmandelb/opt/rtrlib/bin/rtrclient ssh <host> <port> <username>
<private_key> <public_key>

Examples:
/home/dmandelb/opt/rtrlib/bin/rtrclient tcp rpki.realmv6.org 42420
/home/dmandelb/opt/rtrlib/bin/rtrclient ssh rpki.realmv6.org rtr-ssh
~/.ssh/id_rsa ~/.ssh/id_rsa.pub


When I try to connect using tcp, I get a segmentation fault:

$ gdb --args /home/dmandelb/opt/rtrlib/bin/rtrclient tcp
rtr-test.bbn.com 12712
...
(gdb) r
Starting program: /home/dmandelb/opt/rtrlib/bin/rtrclient tcp
rtr-test.bbn.com 12712
[Thread debugging using libthread_db enabled]
Using host libthread_db library
"/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1".
[New Thread 0xb7bc9b70 (LWP 11272)]
(2013/10/11 18:22:53:196290): RTR_MGR: Group(1) status changed to:
CONNECTING
Prefix Prefix Length ASN
(2013/10/11 18:22:53:196333): RTR Socket: State: RTR_CONNECTING

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7bc9b70 (LWP 11272)]
0xb7eb03a7 in *__GI_getaddrinfo (name=0xbffff0a4
"\b\260\004\bJy\375\267\177{\375\267\006|\375\267\233~\375\267\347|\375\267\244\360\377\277\001",
service=0x1 <Address 0x1 out of bounds>, hints=0xb7bc92ec,
pai=0xb7bc92e0)
at ../sysdeps/posix/getaddrinfo.c:2102
2102 ../sysdeps/posix/getaddrinfo.c: No such file or directory.
(gdb) bt
#0 0xb7eb03a7 in *__GI_getaddrinfo (name=0xbffff0a4
"\b\260\004\bJy\375\267\177{\375\267\006|\375\267\233~\375\267\347|\375\267\244\360\377\277\001",
service=0x1 <Address 0x1 out of bounds>, hints=0xb7bc92ec,
pai=0xb7bc92e0)
at ../sysdeps/posix/getaddrinfo.c:2102
#1 0xb7fd7a01 in tr_tcp_open () from /home/dmandelb/rtrlib/librtr.so.0
#2 0xb7fd75b7 in tr_open () from /home/dmandelb/rtrlib/librtr.so.0
#3 0xb7fd83e3 in rtr_fsm_start () from
/home/dmandelb/rtrlib/librtr.so.0
#4 0xb7faac39 in start_thread (arg=0xb7bc9b70) at pthread_create.c:304
#5 0xb7ed578e in clone () at
../sysdeps/unix/sysv/linux/i386/clone.S:130

--
David Eric Mandelberg / dseomn
http://david.mandelberg.org/

Fabian Holler

unread,
Oct 12, 2013, 5:58:02 AM10/12/13
to rtr...@googlegroups.com
Hello David,

thanks for reporting!

On Fri, Oct 11, 2013 at 06:32:09PM -0400, David Mandelberg wrote:
> I tried connecting to my server using ssh, but I just get a help
> message. Am I doing something wrong? Also, what does "rtr-ssh"
> represent?
>
> $ /home/dmandelb/opt/rtrlib/bin/rtrclient ssh rtr-test.bbn.com
> rtr-ssh ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
> Usage:
> /home/dmandelb/opt/rtrlib/bin/rtrclient tcp <host> <port>
> /home/dmandelb/opt/rtrlib/bin/rtrclient ssh <host> <port>
> <username> <private_key> <public_key>

The <port> argument is missing in the SSH example of the usage output. I've fixed
it: https://github.com/rtrlib/rtrlib/commit/746ea2c4389640812477d1756f64821babf56e29

The correct example is:
$ /rtrclient ssh rpki.realmv6.org 22 rtr-ssh ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
rtr-ssh is the SSH username in his example

Try:
$ ./rtrclient ssh rtr-test.bbn.com 22 $USER ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
Are you using version 0.2.2 of rtrlib?
I can't reproduce it and don't see what could caused the invalid address in
the service argument.

Could you run rtrclient with valgrind and send me the output? Hopefully this
will give a hint what caused it.

You could also try to use the current develop version
(https://github.com/rtrlib/rtrlib/tree/develop) instead.


regards

Fabian

David Mandelberg

unread,
Oct 14, 2013, 5:03:47 PM10/14/13
to Fabian Holler, rtr...@googlegroups.com
On 2013-10-12 05:58, Fabian Holler wrote:
> The <port> argument is missing in the SSH example of the usage
> output. I've fixed
> it:
>
> https://github.com/rtrlib/rtrlib/commit/746ea2c4389640812477d1756f64821babf56e29
>
> The correct example is:
> $ /rtrclient ssh rpki.realmv6.org 22 rtr-ssh ~/.ssh/id_rsa
> ~/.ssh/id_rsa.pub
> rtr-ssh is the SSH username in his example
>
> Try:
> $ ./rtrclient ssh rtr-test.bbn.com 22 $USER ~/.ssh/id_rsa
> ~/.ssh/id_rsa.pub

Thanks! I should have read the help message more closely.


> Are you using version 0.2.2 of rtrlib?
> I can't reproduce it and don't see what could caused the invalid
> address in
> the service argument.
>
> Could you run rtrclient with valgrind and send me the output?
> Hopefully this
> will give a hint what caused it.
>
> You could also try to use the current develop version
> (https://github.com/rtrlib/rtrlib/tree/develop) instead.

I'm using the latest git master, which was commit 01326a8 when I built
it. I've attached the output from valgrind, both for the segfault I
mentioned already and for the new segfault I get when I try to use
rpki-rtr over ssh.
rtrclient-ssh.valgrind.log
rtrclient-tcp.valgrind.log

Michael Mester

unread,
Oct 15, 2013, 5:52:23 AM10/15/13
to rtr...@googlegroups.com
Hello,

the cause of this error may be that some important variables are local to function main. See below. I believe that they are not in scope of the new thread. It is hard to reproduce because evene if they are not valid inside the thread, they may or may not be overwritten. At least that is what I think. The solution could be to define them outside of a function to make them global or to call malloc.

    enum mode_t { TCP, SSH } mode;
    char* host;
    char* port;
    char* user;
    char* privkey;
    char* pubkey;
        tr_socket tr_sock;
    rtr_socket rtr;

I hope this is helpful.

Greetings
Michael Mester

David Mandelberg

unread,
Oct 15, 2013, 1:09:26 PM10/15/13
to rtr...@googlegroups.com
On 2013-10-15 05:52, Michael Mester wrote:
> Hello,
>
> the cause of this error may be that some important variables are
> local
> to function main. See below. I believe that they are not in scope of
> the new thread. It is hard to reproduce because evene if they are not
> valid inside the thread, they may or may not be overwritten. At least
> that is what I think. The solution could be to define them outside of
> a function to make them global or to call malloc.

Thanks! I (locally) added some strdup() and malloc() calls and it works
for me now.

Fabian Holler

unread,
Oct 15, 2013, 3:18:38 PM10/15/13
to rtr...@googlegroups.com
Hello Michael,

On Tue, Oct 15, 2013 at 02:52:23AM -0700, Michael Mester wrote:
> the cause of this error may be that some important variables are local to
> function main. See below. I believe that they are not in scope of the new
> thread. It is hard to reproduce because evene if they are not valid inside
> the thread, they may or may not be overwritten. At least that is what I
> think.
> [..]

Thanks, that helped a lot. It was an out of scope problem.
It's now fixed:
https://github.com/rtrlib/rtrlib/commit/0b105227e9373a4b9004e7ef4d42060b637b80a8

Also thanks to David for reporting the problem.
Reply all
Reply to author
Forward
0 new messages