Re: Segmentation violation after reading from file
- From: Michael Meeks <michael ximian com>
- To: pvosta unionbio-eu com
- Cc: ORBit list <orbit-list gnome org>
- Subject: Re: Segmentation violation after reading from file
- Date: Thu, 09 Oct 2003 11:09:13 +0100
Hi Peter,
On Wed, 2003-10-08 at 16:38, Peter Van Osta wrote:
> I am currently implementing the sorage and retrieval of CORBA structures
> and I am getting segmentation violations when retrieving the objects
Hmm,
> (example se below). Wrting them to disk works as it doesn't give any
> errors
That's also an interestin assertion.
> 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 ?
How do you think 'write' works ? show me how you could possibly
implement fwrite (void *, size_t, size_t, FILE *) to load pointer
dereferenced strings, and CORBA allocate them into memory ? how would
the code look ? - perhaps here is the pseudo code ;->
size_t
fwrite (void *mem, size_t size, size_t nmemb, FILE *stream)
{
1. ... guess C type of void * ...
2. ... guess C type is a CORBA type ...
3. ... generically walk C type, dereferencing pointers ...
4. ... keep cache of dereferenced pointers to avoid loops ...
5. ... assign each element a global id ...
6. ... start serialising id / element pairs to disk with
hierarchical information ...
}
The problem with this is - that fwrite writes raw bytes straight to
disk (as you might expect), steps 1 -> 3 are (unfortunately) impossible.
> The error only occurs in those structures where I have changed the
> content of a "string" element prior to wrting them to disk
Grief - well - it's possible that owing to some incredible fluke, the
2nd time you run the program the strings are allocated at the same place
- and thus reading a pointer value in _might_ work.
> 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.
You need to carefully hand-marshal each of the elements individually to
disk in your binary file format; and then hand marshal them back. I
would recommend using XML for this.
I would suggest though that you use ghex2 on your existing file first
to see what's actually happening.
Regards,
Michael.
--
michael@ximian.com <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]