kastnermario / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

containers larger than 128 elements break the parser #176

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Create yaml file with map container
myKey: [true, true, true,.....]
with > 128 elements on the container.

What is the expected output? What do you see instead?
succesful parse.  Instead blows up on
YAML::Node doc;
parser.GetNextDocument(doc);

What version of the product are you using? On what operating system?
0.3.0
VS2010-latest x64-only

Please provide any additional information below.
This will also break it

myAwesomeKey:
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]
  - [0, 0, 0, 0, 4.2039e-045, 0, 1.25839e-036, 0, 3.17244e+023, 0, 2.03793, 1.4013e-045, 1.1858e-035, 0, 0, 0]

Original issue reported on code.google.com by JohnMich...@gmail.com on 12 Nov 2012 at 3:05

GoogleCodeExporter commented 8 years ago
I can't reproduce this in either case. (I'm on OS X instead of Windows, so it's 
possible that's the source of the difference.)

Could you be more specific about what it means to "blow up" or "break"? Does it 
throw an exception? Does it segfault? If it segfaults, could you give a stack 
trace?

Thanks!

Original comment by jbe...@gmail.com on 13 Nov 2012 at 12:20

GoogleCodeExporter commented 8 years ago
I will build up a more complete report today.  Thanks for the quick response.

Original comment by JohnMich...@gmail.com on 13 Nov 2012 at 9:43

GoogleCodeExporter commented 8 years ago
Windows 7x64
Build VS2010-latest x64-only build, debug mode optimizations turned off

Here is how I parse

.
.
std::ifstream fin(buildFilenamePath(m_shortName).toStdString());
if( fin.fail() )
{
  return false;
}
YAML::Parser parser(fin);
fin.close();
YAML::Node doc;
parser.GetNextDocument(doc);
.
.

I have attached two yaml files, one which will GetNextDocument without failing, 
but then actually in my parser the call to 
if(const YAML::Node *pName = doc.FindValue("myKey"))
for at least one of the keys towards the end of the file fails and says it 
wasn't found.  If I remove data and shrink the file to all 4-element containers 
everything works perfectly.
The other file i'm attaching actually makes the parser choke and die on 
GetNextDocument with the below output and stacktrace

Output:
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: YAML::ParserException at memory location 0x07f09720..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: YAML::ParserException at memory location 0x07f09720..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: YAML::ParserException at memory location 0x07f09720..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: YAML::ParserException at memory location 0x07f09720..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: [rethrow] at memory location 0x00000000..
First-chance exception at 0x000007fefdffcaed in declipse.exe: Microsoft C++ 
exception: YAML::ParserException at memory location 0x07f09720..
Unhandled exception at 0x000007fefdffcaed in myExe.exe: Microsoft C++ 
exception: YAML::ParserException at memory location 0x07f09720..

Stack Trace (not very useful even with the mdd library and symbols available)
KernelBase.dll!000007fefdffcaed()   
[Frames below may be incorrect and/or missing, no symbols loaded for 
KernelBase.dll] 
msvcr100d.dll!__CxxCallCatchBlock()  + 0x273 bytes  
msvcr100d.dll!__CxxCallCatchBlock()  + 0x176 bytes  
ntdll.dll!RcFrameConsolidation()  + 0x3 bytes   
QtCored4.dll!000000005903fde9()     
QtCored4.dll!0000000058e8a3f5()     
myExe.exe!InputDevice::run()  Line 268 + 0xe bytes  C++
QtCored4.dll!0000000058e8f1a6()     
msvcr100d.dll!_beginthreadex()  + 0x2d5 bytes   
msvcr100d.dll!_beginthreadex()  + 0x294 bytes   
kernel32.dll!00000000776a652d()     
ntdll.dll!RtlUserThreadStart()  + 0x21 bytes    

In performing the test this time I got the latest from old-api hg branch (the 
original bug report was filed against the 0.3.0 as packaged on the website).  I 
then build the library using CMake (cmake-gui) using
APPLE_UNIVERSAL_BIN              0
BUILD_SHARED_LIBS                0
CMAKE_INSTALL_PREFIX             C:/Program Files/YAML_CPP 
MSVC_SHARED_RT                   1
MSVC_STHREADED_RT                0
YAML_CPP_BUILD_CONTRIB           1
YAML_CPP_BUILD_TOOLS             1

Then click configure and then generate using "Visual Studio 10 Win64".  Open 
the generated MSVC 2010 solution and Rebuild Solution in both release and debug 
mode.  Copy .lib's into place and update config files to link debug or release 
builds accordingly.  Copy yaml-cpp/include+src+etc... into my thirdparty 
directory and set projects to include the yaml-cpp/include/yaml-cpp/ folder.  

Original comment by JohnMich...@gmail.com on 13 Nov 2012 at 10:15

Attachments:

GoogleCodeExporter commented 8 years ago
To be even more explicit, the key which isn't found on the silent_death example 
is the energyWindowPairs key (and its values).

Original comment by JohnMich...@gmail.com on 13 Nov 2012 at 10:19

GoogleCodeExporter commented 8 years ago
OK, realized I could actually catch the exception, duh.  Here is what I'm 
seeing, although I don't agree with its error message.

This comes from the loud_fail file
e   {mark={...} msg="end of sequence flow not found" }  YAML::Exception
  std::runtime_error    {...}   std::runtime_error
  std::exception    {_Mywhat=0x0000000006be6cc0 "yaml-cpp: error at line 16, column 1: end of sequence flow not found" _Mydofree=true } std::exception
    __vfptr 0x000000013f857be0 const YAML::Exception::`vftable' *
      [0]   0x000000013f18e1d0 YAML::Exception::`scalar deleting destructor'(unsigned int)  *
      [1]   0x000000013f1ecef2 std::exception::what *
    _Mywhat 0x0000000006be6cc0 "yaml-cpp: error at line 16, column 1: end of sequence flow not found"   const char *
        121 'y' const char
      _Mydofree true    bool
  mark  {pos=2048 line=15 column=0 }    YAML::Mark
  msg   "end of sequence flow not found"    std::basic_string<char,std::char_traits<char>,std::allocator<char> >

Original comment by JohnMich...@gmail.com on 13 Nov 2012 at 10:31

GoogleCodeExporter commented 8 years ago
It looks like you're closing the stream before you parse the document:

YAML::Parser parser(fin);
fin.close();
YAML::Node doc;
parser.GetNextDocument(doc);

The parser reads from the stream lazily, so my guess is that what's happening 
is that the stream has buffered some of the input, which the parser reads, but 
not all of it, so it's crashing at that point.

Try to remove the fin.close() line.

Original comment by jbe...@gmail.com on 13 Nov 2012 at 3:08

GoogleCodeExporter commented 8 years ago
Thanks will give that a try.

Original comment by JohnMich...@gmail.com on 15 Nov 2012 at 6:20

GoogleCodeExporter commented 8 years ago
If this didn't work for you, please let me know so I can reopen this issue.

Original comment by jbe...@gmail.com on 27 Nov 2012 at 2:11