Hi,

I was making some code changes to pvfs and my code change has exposed
a bug in pvfs. When you use user defined hints (strings), the function
encode_PINT_hint() cores while calling the macro encode_string(). The
macro is designed to be called with arguments (char **, char ***), but
in this case, has been called with (char **, char **) and hence you
get a segmentation fault.

All src code referenced is from pvfs-2.8.1

"src/common/misc/pint-hint.c"
331             /* encode the hint using the encode function provided */
332             tmp_hint->encode(pptr, tmp_hint->value); ----> This
shd be changed to tmp_hint->encode(pptr, &tmp_hint->value);

"src/proto/endecode-funcs.h"
103 #define encode_string(pptr,pbuf) do { \
104     u_int32_t len = 0; \
105     if (*pbuf) \
106         len = strlen(*pbuf); \  <------------------ cores in strlen()
107     *(u_int32_t *) *(pptr) = htobmi32(len); \
108     if (len) { \
109         memcpy(*(pptr)+4, *pbuf, len+1); \
110         *(pptr) += roundup8(4 + len + 1); \
111     } else { \
112         *(u_int32_t *) *(pptr) = 0; \
113         *(pptr) += 8; \
114     } \
115 } while (0)


The core stack is pasted below:

0:  Program received signal SIGSEGV, Segmentation fault.
0:  0x080f9e07 in encode_func_string (pptr=0x9d55950, x=0x9d57c78)
0:      at src/common/misc/pint-hint.c:22
0:  22  DEFINE_STATIC_ENDECODE_FUNCS(string, char *);
0:  (gdb) bt
0:  #0  0x080f9e07 in encode_func_string (pptr=0x9d55950, x=0x9d57c78)
0:      at src/common/misc/pint-hint.c:22
0:  #1  0x080fa4cf in encode_PINT_hint (pptr=0x9d55950, hint=0x9d55bf8)
0:      at src/common/misc/pint-hint.c:332
0:  #2  0x0811356b in encode_PVFS_server_req (pptr=0x9d55950, x=0x9d554d8)
0:      at src/proto/pvfs2-req-proto.h:1757
0:  #3  0x08110989 in lebf_encode_req (req=0x9d554d8, target_msg=0x9d55928)
0:      at src/proto/PINT-le-bytefield.c:377
0:  #4  0x0810fb55 in PINT_encode (input_buffer=0x9d554d8,
0:      input_type=PINT_ENCODE_REQ, target_msg=0x9d55928, target_addr=3,
0:      enc_type=ENCODING_LE_BFIELD) at src/proto/PINT-reqproto-encode.c:111
0:  #5  0x080f6045 in msgpairarray_post (smcb=0x9d572b8, js_p=0xbf9b2de4)
0:      at src/common/misc/msgpairarray.sm:209
0:  #6  0x080f865f in PINT_state_machine_invoke (smcb=0x9d572b8, r=0xbf9b2de4)
0:      at src/common/misc/state-machine-fns.c:132
0:  #7  0x080f8a0b in PINT_state_machine_next (smcb=0x9d572b8, r=0xbf9b2de4)
0:      at src/common/misc/state-machine-fns.c:309
0:  #8  0x080f8a44 in PINT_state_machine_continue (smcb=0x9d572b8, r=0xbf9b2de4)
0:      at src/common/misc/state-machine-fns.c:327
0:  #9  0x080f87b2 in PINT_state_machine_start (smcb=0x9d572b8, r=0xbf9b2de4)
0:      at src/common/misc/state-machine-fns.c:202
0:  #10 0x080c2c3f in PINT_client_state_machine_post (smcb=0x9d572b8,
0:      op_id=0xbf9b2ed0, user_ptr=0x0)
0:      at src/client/sysint/client-state-machine.c:405
0:  #11 0x080ccd20 in PVFS_isys_io (ref=
0:        {handle = 2305843009213693948, fs_id = 981299054, __pad1 = 0},
0:      file_req=0x9d57880, file_req_offset=0, buffer=0xb7744008,
0:      mem_req=0x9d57af8, credentials=0x9d44590, resp_p=0xbf9b2f44,
0:      io_type=PVFS_IO_READ, op_id=0xbf9b2ed0, hints=0x9d445f8, user_ptr=0x0)
0:      at src/client/sysint/sys-io.sm:346
0:  #12 0x080ccdcb in PVFS_sys_io (ref=
0:        {handle = 2305843009213693948, fs_id = 981299054, __pad1 = 0},
0:      file_req=0x9d57880, file_req_offset=0, buffer=0xb7744008,
0:      mem_req=0x9d57af8, credentials=0x9d44590, resp_p=0xbf9b2f44,
0:      io_type=PVFS_IO_READ, hints=0x9d445f8) at
src/client/sysint/sys-io.sm:370
0:  #13 0x08084f52 in ADIOI_PVFS2_ReadContig (fd=0x9d41a60, buf=0xb7744008,
0:      count=1048576, datatype=1275070475, file_ptr_type=101, offset=0,
0:      status=0xbf9b3068, error_code=0xbf9b2fc4) at ad_pvfs2_read.c:63
0:  #14 0x0805084b in MPIOI_File_read (mpi_fh=0x9d41a60, offset=0,
0:      file_ptr_type=101, buf=0xb7744008, count=1048576, datatype=1275070475,
0:      myname=0x8169e14 "MPI_FILE_READ", status=0xbf9b3068) at read.c:141
0:  #15 0x08050a25 in PMPI_File_read (mpi_fh=0x9d41a60, buf=0xb7744008,
0:      count=1048576, datatype=1275070475, status=0xbf9b3068) at read.c:52
0:  #16 0x0804b81b in main (argc=1, argv=0xbf9b3fb4) at read.c:90

Regards,
Christina.
_______________________________________________
Pvfs2-developers mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-developers

Reply via email to