Boost serialization : Stream error exception

S

smith4894

{ 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! ]
 
K

kanze

{ 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! ]
 
N

Nicola Musatti

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! ]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top