[gnet] SIGSEGV + gnet_tcp_socket_get_io_channel() + HELP!




hi everyone

i was trying out mr.helder's "hfetch" code and ran into the following
problem. the original code ran alright, but when i tried to make it a part
of a larger piece of code, my program crashed. i  made changes that are at
best miniscule. here's an excerpt:

/************************************************************************/
 /*open the local file for writing into */

  fp = fopen(file_name, "w");
  if(fp == NULL)
          pthread_exit(NULL);

  printf("\nOpened local file for writing into");


  /* Create the address */
  addr = gnet_inetaddr_new(server, port);
  if (addr == NULL)
          pthread_exit(NULL);

  printf("\nCreated Address");


  /* Create the socket */
  socket = gnet_tcp_socket_new(addr);
  gnet_inetaddr_delete (addr);
  if (socket == NULL)
        pthread_exit(NULL);

  printf("\nGot Socket");


  /* Get the IOChannel */
  iochannel = gnet_tcp_socket_get_io_channel(socket);
  if (iochannel == NULL)
	pthread_exit(NULL);

  printf("\nGot IOChannel to socket");


/***********************************************************************************/

i have tried to write to the stream represented by FILE *fp instead of
stdout and replaced the g_assert(...) statements with the pthread_exit()s.

i got the following gdb messages:
/***************************************************************/
Opened local file for writing into
Created Address
Got Socket
GLib-WARNING **: Need to set the channel buffered before setting the
encoding.


GLib-WARNING **: Assuming this is what you meant and acting accordingly.


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1087077568 (LWP 20147)]
0x4201693a in __gconv_close () from /lib/tls/libc.so.6

/****************************************************************/
as you can see, the program gets the GtcpSocket, but never prints out the
"Got IOChannel" statement

It runs into trouble with the gnet_tcp_socket_get_io_channel() call.


here's a stack trace:

(gdb) bt
#0  0x4201693a in __gconv_close () from /lib/tls/libc.so.6
#1  0x42016001 in iconv_close () from /lib/tls/libc.so.6
#2  0x4036e02f in g_iconv_close () from /usr/lib/libglib-2.0.so.0
#3  0x4037ab97 in g_io_channel_set_encoding () from
/usr/lib/libglib-2.0.so.0
#4  0x40343de2 in gnet_private_io_channel_new (sockfd=14) at
gnet-private.c:108
#5  0x4034812a in gnet_tcp_socket_get_io_channel (socket=0x80be250)
    at tcp.c:719
#6  0x08050c73 in hfetch (server=0x80b8310 "202.141.81.48", port=8089,
    filename=0x80be210 "/basic.o") at hfetch.c:132
#7  0x08050b03 in stripURL (url_void=0x8064700) at hfetch.c:74
#8  0x400332b6 in start_thread () from /lib/tls/libpthread.so.0
/*******************************************************************/

do i need to use glib's
set_io_channel_encoding() & set_io_channel_buffered()
routines?

Can someone please help me out here.

Thanks a million

-- 
Pritish Jetley



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]