Re: libxml++: interactive read state loop



I've made more tests with the libxml++ example program examples/textreader. I've modified the input file in different ways. I have not been able to make it loop indefinitely. State is either Interactive or EndOfFile all the time. I think that's normal. But I never see node type None. Probably that would require a special input file.

I think we need an input file that can reproduce the fault.
You can also try asking on the xml gnome org mailing list. That's a mailing list for the underlying C package, libxml2. If you're lucky, you may find someone there who knows what might cause an indefinite loop in your program.

Kjell

2014-03-12 14:07, Aleksei Artemev skrev:
Hi, Kjell,

Interactive state was the only one I observed and the loop logged. My previous code illustrated how I handle reader.read() in a while loop. These are logs I have:

20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000] Reading...current model position name: root
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000] --- node ---
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]        type: 0
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]        name:
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]       depth: 1
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]       state: 1
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000] Reading...current model position name: root
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000] --- node ---
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]        type: 0
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]        name:
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]       depth: 1
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]       state: 1
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000] Reading...current model position name: root
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000] --- node ---
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]        type: 0
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]        name:
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]       depth: 1
20140224T173124.459 DEBUG  XMLCODEC         [0xe31a000]       state: 1
...and so on...

Logs are printed as following:
        while (reader->read()) {
            LOG_DEBUG(m_log, "[%p] Reading...current model position name: %s", this, pos->tag_name.c_str());

            depth = reader->get_depth() + 1;
            name = reader->get_name();

            switch (reader->get_read_state()) {
                case xmlpp::TextReader::Error:
                {
                    LOG_ERROR(m_log, "[%p] --- error node ---", this);
                    LOG_ERROR(m_log, "[%p]        type: %d", this, reader->get_node_type());
                    LOG_ERROR(m_log, "[%p]        name: %s", this, name.c_str());
                    LOG_ERROR(m_log, "[%p]       depth: %d", this, depth);
                    return XMLResult(xmlRSIntError);
                }
                    break;
                case xmlpp::TextReader::EndOfFile:
                {
                    LOG_DEBUG(m_log, "[%p] --- end of file node ---", this);
                    LOG_DEBUG(m_log, "[%p]        type: %d", this, reader->get_node_type());
                    LOG_DEBUG(m_log, "[%p]        name: %s", this, name.c_str());
                    LOG_DEBUG(m_log, "[%p]       depth: %d", this, depth);
                }
                    break;
                default:
                    LOG_DEBUG(m_log, "[%p] --- node ---", this);
                    LOG_DEBUG(m_log, "[%p]        type: %d", this, reader->get_node_type());
                    LOG_DEBUG(m_log, "[%p]        name: %s", this, name.c_str());
                    LOG_DEBUG(m_log, "[%p]       depth: %d", this, depth);
                    LOG_DEBUG(m_log, "[%p]       state: %d", this, reader->get_read_state());
            }

Unfortunately I have no more information ((( Defect is still open and waits for step forward. I wish we could catch the fault so I could explain little more to you to make library more stable (or we find some bug in our code :) ).
If you will have any idea looking from information I just gave you, please, share it.
Thanks again for your support.

Aleskei.


On Wed, Mar 12, 2014 at 3:52 PM, Kjell Ahlstedt <kjell ahlstedt bredband net> wrote:
You subscribe here: https://mail.gnome.org/mailman/listinfo/libxmlplusplus-list

I made some quick tests with the libxml++ example program at https://git.gnome.org/browse/libxml++/tree/examples/textreader

I added code to see the node type and read state after each call to reader.read():
      std::cout << "node_type: " << reader.get_node_type() << std::endl;
      std::cout << "read_state: " << reader.get_read_state() << std::endl;

When a small file is read, the state is EndOfFile all the time. Probably the program reads a block of data from the input file, and reader.read() then reads a node at a time from internal memory.
When I added some kilobytes of blank space here and there in the input file, the state is Interactive most of the time, until it becomes EndOfFile. Interactive seems to be the normal state until the last block has been read from the file. Have you seen other read states when your program does not run into an infinite loop?

Kjell

2014-03-12 10:53, Aleksei Artemev skrev:
Hi Kjell,

  I am not subscribed I think and also not sure why it was delayed :( How can I?
  Anyway, I have not done any fix yet to handle type None, but the problem is what I cant provide you with the input file (buffer) since we did not log it when we've got into such condition. I believe Interactive state is one of the keys to that root cause. So far, our server did not enter same loop again, but it can happen anytime. How Interactive state is triggered in the library?

PS. Thanks for your response!

Aleksei.







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]