Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Boost serialization : Stream error exception (http://www.velocityreviews.com/forums/t456409-boost-serialization-stream-error-exception.html)

smith4894@excite.com 08-24-2006 12:54 AM

Boost serialization : Stream error exception
 
{ not sure you're aware of that but there are the newsgroups for all
major operating systems. you might want to try asking in the forum
'comp.os.linux.development.apps', since memory-mapped files are not
a language-supported structure, they are platform-specific. -mod }

I'm trying to use boost serialization to serialize/deserialize data to
and from a mmap'd file. I have my own ostream/istream classes that
essentially read/write bytes from a mmap'd file. The process works fine
except on some rare occasions (With different objects/number of
objects), in which case boost throws a "stream error" exception. Any
ideas what could trigger this? A search of the Boost archives indicated
other people had the same problem, where the solution was "use binary
mode when you open the file"... but I'm not using a file on disk, I'm
using a mmap'd file.

The OS i'm using is Linux.


Thanks for any suggestions...


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


kanze 08-24-2006 01:34 PM

Re: Boost serialization : Stream error exception
 
smith4894@excite.com wrote:
> { not sure you're aware of that but there are the newsgroups for all
> major operating systems. you might want to try asking in the forum
> 'comp.os.linux.development.apps', since memory-mapped files are not
> a language-supported structure, they are platform-specific. -mod }


> I'm trying to use boost serialization to serialize/deserialize data to
> and from a mmap'd file. I have my own ostream/istream classes that
> essentially read/write bytes from a mmap'd file. The process works fine
> except on some rare occasions (With different objects/number of
> objects), in which case boost throws a "stream error" exception.


On reading, or on writing? And what does "stream error" mean: I
would expect that it refers to an error returned by the
iostream, but it would be best to be sure---it could also refer
to an error in the format of the input stream (unexpected EOF,
etc.).

> Any ideas what could trigger this? A search of the Boost
> archives indicated other people had the same problem, where
> the solution was "use binary mode when you open the file"...
> but I'm not using a file on disk, I'm using a mmap'd file.


The image must be binary, i.e. when you read, you must be
guaranteed to see exactly the same bytes as when you wrote.

Writing to a mmap'd file can be tricky. Basically, mmap (at
least under Unix) presents a view of a fixed length file; if a
write would extend the file, you have to take special actions.
If you don't, it's entirely possible that when you reread the
file, you loose a bit at the end. (It's also possible, of
course, that you core dump on writing.)

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Nicola Musatti 08-24-2006 01:39 PM

Re: Boost serialization : Stream error exception
 

smith4894@excite.com wrote:
[...]
> I'm trying to use boost serialization to serialize/deserialize data to
> and from a mmap'd file. I have my own ostream/istream classes that
> essentially read/write bytes from a mmap'd file. The process works fine
> except on some rare occasions (With different objects/number of
> objects), in which case boost throws a "stream error" exception. Any
> ideas what could trigger this? A search of the Boost archives indicated
> other people had the same problem, where the solution was "use binary
> mode when you open the file"... but I'm not using a file on disk, I'm
> using a mmap'd file.


In my opinion you stand better chances of receiving help if you post to
the Boost User mailing list:
http://www.boost.org/more/mailing_lists.htm#users

Cheers,
Nicola Musatti


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]



All times are GMT. The time now is 04:32 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.