Segmentation violation after reading from file
- From: Peter Van Osta <pvosta unionbio-eu com>
- To: ORBit list <orbit-list gnome org>
- Subject: Segmentation violation after reading from file
- Date: Wed, 08 Oct 2003 17:38:01 +0200
Hi,
I am currently implementing the sorage and retrieval of CORBA structures
and I am getting segmentation violations when retrieving the objects
(example se below). Wrting them to disk works as it doesn't give any
errors, but the retrieval of the structures and their transfer back to
the client causes a crash at the moment of the transfer.
Everything looks fine until the actual transfer back to the client.
The structures contain "strings", should I copy those subelements
intdividualy with "CORBA_string_dup" or allocate them before sensidng
them back ?
The error only occurs in those structures where I have changed the
content of a "string" element prior to wrting them to disk and the
segmentation violation then occurs at the moment when the copmplete
structre is retreived over the ORBit link from server to client.
I print our the conntent of all the strings in the structure before
transfer and their content is valid on the server side.
What am I doing wrong in retrieving these structures from disk and
sending them back from the server to the client. On both the client and
the server the objects and their string subelementts are allocated at
startup.
Best regards,
Peter Van Osta
----------------------------------------------
e.g.:
ezxrdrprotocol_srvr->name = CORBA_string_dup( "-" );
ezxrdrprotocol_srvr->location = CORBA_string_alloc(EZX_FIL_NAMLEN );
exerpt from a function which handles the retrieval of data from disk and
sends the result tot the client:
int status = IE_OK;
EzxS_EzxRdrDatastoreObj *retval = NULL;
int val = 0;
FILE *fp = NULL;
char filbuf[EZX_FIL_PATHLEN];
...
*filbuf = '\0';
*message = CORBA_string_dup( "-" );
/* Always allocate this first */
retval = EzxS_EzxRdrDatastoreObj__alloc( );
retval = ORBit_copy_value( Ezxstrg, TC_EzxS_EzxRdrDatastoreObj );
ezxrdrdatastore_srvr = ORBit_copy_value( Ezxstrg,
TC_EzxS_EzxRdrDatastoreObj );
sprintf( filbuf, "%s%c%s", ezxrdrdatastore_srvr->protocol, DIRSEP,
"Ezx_Storage.ezp" );
if( bugfind == TRUE )fprintf( stdout, "Reading: %s\n", filbuf );
fp = fopen( filbuf, "rb" );
if( !fp )
status = IE_FILE;
if( fp ){
val = fread( retval, sizeof( ezxrdrdatastore_srvr ), 1, fp );
if( ferror( fp ) || feof( fp ) )
status = IE_FILE;
}
if( fp ){
if( fclose( fp ) == EOF )
status = IE_FILE;
}
/* Make sure server object matches client object */
if( status >= IE_OK )
ezxrdrdatastore_srvr = ORBit_copy_value( retval, TC_EzxS_EzxRdrDatastoreObj );
...
fprintf( stdout, "Name %s\n", ezxrdrdatastore_srvr->name );
...
fprintf( stdout, "Name %s\n", retval->name );
...
return retval;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]