Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. debugging a Boost serialization assertion

debugging a Boost serialization assertion

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingjsonhelptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alexander Kindel
    wrote on last edited by
    #1

    I'm trying to use Boost serialization in a C++ project, and my code has triggered the assertion on line 103 of this file. That's the line

    BOOST_ASSERT(false);

    in the bottom-most function in the file. What kinds of things can cause this failure? The context is that I have a class called Board, whose serialize() overload starts by trying to serialize the member

    std::arraym_whiteArmy

    where Piece is another of my own classes. Trying to serialize m_whiteArmy is what triggers the assert. I've tried putting a breakpoint at the top of Piece's serialize() overload. The assertion triggers before it's reached. I would include a compileable example, but when I've tried writing a toy program to replicate the problem, the toy program has worked. The two most suspicious things I can think of that my attempts at toy programs haven't replicated are that the Board object I'm trying to serialize is a global, and the project is spread over multiple files. Piece is a base class, and m_whiteArmy stores pointers to derived Piece objects, so maybe it matters which file I use

    BOOST_CLASS_EXPORT_GUID

    to register the derived classes in, and I've chosen the wrong one? Maybe this is all irrelevant - I have no idea where to begin.

    J 1 Reply Last reply
    0
    • A Alexander Kindel

      I'm trying to use Boost serialization in a C++ project, and my code has triggered the assertion on line 103 of this file. That's the line

      BOOST_ASSERT(false);

      in the bottom-most function in the file. What kinds of things can cause this failure? The context is that I have a class called Board, whose serialize() overload starts by trying to serialize the member

      std::arraym_whiteArmy

      where Piece is another of my own classes. Trying to serialize m_whiteArmy is what triggers the assert. I've tried putting a breakpoint at the top of Piece's serialize() overload. The assertion triggers before it's reached. I would include a compileable example, but when I've tried writing a toy program to replicate the problem, the toy program has worked. The two most suspicious things I can think of that my attempts at toy programs haven't replicated are that the Board object I'm trying to serialize is a global, and the project is spread over multiple files. Piece is a base class, and m_whiteArmy stores pointers to derived Piece objects, so maybe it matters which file I use

      BOOST_CLASS_EXPORT_GUID

      to register the derived classes in, and I've chosen the wrong one? Maybe this is all irrelevant - I have no idea where to begin.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Start by having a look at the full code containing the assert statement:

      BOOST_ARCHIVE_DECL(const basic_serializer *)
      basic_serializer_map::find(
      const boost::serialization::extended_type_info & eti
      ) const {
      const basic_serializer_arg bs(eti);
      map_type::const_iterator it;
      it = m_map.find(& bs);
      if(it == m_map.end()){
      BOOST_ASSERT(false);
      return 0;
      }
      return *it;
      }

      The assertion is thrown when the specified element can't be found in the container (see map::find - C++ Reference[^] ). Locate where the find function is called in your code and check the passed argument.

      A 1 Reply Last reply
      0
      • J Jochen Arndt

        Start by having a look at the full code containing the assert statement:

        BOOST_ARCHIVE_DECL(const basic_serializer *)
        basic_serializer_map::find(
        const boost::serialization::extended_type_info & eti
        ) const {
        const basic_serializer_arg bs(eti);
        map_type::const_iterator it;
        it = m_map.find(& bs);
        if(it == m_map.end()){
        BOOST_ASSERT(false);
        return 0;
        }
        return *it;
        }

        The assertion is thrown when the specified element can't be found in the container (see map::find - C++ Reference[^] ). Locate where the find function is called in your code and check the passed argument.

        A Offline
        A Offline
        Alexander Kindel
        wrote on last edited by
        #3

        I found that what displayed when I hovered my cursor over the variable eti just before the assert triggered while debugging contained, among other things, the string "rook". That's the string I had associated with the derived Piece class I would expect the first element of m_whiteArmy to point to an element of using BOOST_CLASS_EXPORT_GUID, so I figured there was something wrong with how I did that association. I tried moving my calls of that macro from the top of the Piece cpp file to the top of the main file, and the assertion has gone away. I wish I knew why this is correct and what I'd done before wasn't, but it least it seems to be working now.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups