can print from command line, but cannot get it from the program-Collection of common programming errors

I use gdb to debug my program, when I unpack a message and wanna print it, I got a problem. It seems that i can print from command line in the terminal, but when program goes to the printf("%d has received msg: ", msg->connid);, I got the problem,

Program received signal SIGSEGV, Segmentation fault.
    0xb7ff6301 in ?? () from /lib/ld-linux.so.2

(gdb)n
154     LSPMessage* msg = lspmessage__unpack(NULL, msg_len, buf);
(gdb) n
156     memcpy(pld, msg->payload.data, msg->payload.len);
(gdb) p msg->payload.data
$1 = (uint8_t *) 0x804c038 "Connectedrt,\031"
(gdb) p msg->connid
$2 = 1
(gdb) p msg->payload.len
$3 = 9
174     printf("%d has received msg: ", msg->connid);  // required field
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0xb7ff6301 in ?? () from /lib/ld-linux.so.2