majintao0131 / yaml-cpp

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

Unexplained crash with YAML::LoadFile() #235

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call YAML::LoadFile("File.yaml");
2. File.Yaml only contains the line "[1,2,3]" without quotes.

What is the expected output? What do you see instead?

Crash, no exception is thrown.

What version of the product are you using? On what operating system?

yaml-cpp 0.5.1
Windows 7 64 bit (Compiled library and program using 32bit g++ (tdm-2) 
4.8.1-dw2).

Shame there's no irc channel for this library.

Original issue reported on code.google.com by ARandomFurry on 25 Jan 2014 at 5:08

GoogleCodeExporter commented 9 years ago
Interesting; I can't reproduce this on OS X with clang. What kind of crash is 
it? SEGV? Can you post a stack trace?

Original comment by jbe...@gmail.com on 25 Jan 2014 at 5:46

GoogleCodeExporter commented 9 years ago
I can't reproduce the problem on my windows 7 32bit machine. Both use the same 
version of Yaml-cpp and Mingw, and now it suddenly works again on my labtop 
(with and without the debugger attatched). Sometimes the programming gods hate 
me. I will look into this further though.

Original comment by ARandomFurry on 26 Jan 2014 at 3:37

GoogleCodeExporter commented 9 years ago
Yay, got it to crash again, stack trace:

#0  0x00457033 in std::locale::operator=(std::locale const&) ()
#1  0x0045c114 in std::ios_base::_M_init() ()
#2  0x004cc522 in std::basic_ios<char, std::char_traits<char> 
>::init(std::basic_streambuf<char, std::char_traits<char> >*) ()
#3  0x00404b7d in YAML::LoadFile(std::string const&) ()
#4  0x0040184c in Lua_LoadYamlFile (State=0x854928) at Code.cpp:58
#5  0x0044b919 in luaD_precall ()
#6  0x0044bb78 in luaD_call ()
#7  0x0043ad6c in f_call ()
#8  0x0044b2c4 in luaD_rawrunprotected ()
#9  0x0044bda2 in luaD_pcall ()
#10 0x0043c247 in lua_pcallk ()
#11 0x0047b10a in Lua::Call<char const*> (State=0x854928, Function=...) at 
LuaCode.hpp:28
#12 0x004022d6 in main () at Code.cpp:153

LuaCode.hpp and Code.cpp are my project files (this project is unnamed hence 
the poor filename choices), #0 to #3 are the relevant ones I assume.

Original comment by ARandomFurry on 27 Jan 2014 at 2:43

GoogleCodeExporter commented 9 years ago
Sorry for triple post, blame the forum not having an edit button. The function 
call to YAML::LoadFile is within a try-catch block, so the segv is from 
dereferencing null, integer division by zero, double free, etc. Not from any 
thrown exception (I catch ...).

Original comment by ARandomFurry on 27 Jan 2014 at 2:47

GoogleCodeExporter commented 9 years ago
Thanks for the investigation! Could you:

1) post the exact code you're using, and

2) whittle down the example so it *just* uses yaml-cpp? (In other words, try to 
remove any Lua calls.)

Thanks!

Original comment by jbe...@gmail.com on 27 Jan 2014 at 5:02

GoogleCodeExporter commented 9 years ago
Sorry for the long delay, still need to set up email notification.

File.cpp

#include <yaml-cpp/yaml.h>

int main(){
    YAML::Node Root=YAML::LoadFile("YamlFile.yaml");
    return 0;
}

YamlFile.yaml

[1,2,3]

gdb output:

Program received signal SIGSEGV, Segmentation fault.
0x0042c0f3 in std::locale::operator=(std::locale const&) ()

Is this stripped down enough?

Stack trace:

#0  0x0042c0f3 in std::locale::operator=(std::locale const&) ()
#1  0x0042fdc4 in std::ios_base::_M_init() ()
#2  0x0049b892 in std::basic_ios<char, std::char_traits<char> 
>::init(std::basic_streambuf<char, std::char_traits<char> >*) ()
#3  0x004019e5 in YAML::LoadFile(std::string const&) ()
#4  0x0040140e in main ()

Original comment by ARandomFurry on 1 Feb 2014 at 3:38

GoogleCodeExporter commented 9 years ago
Finally getting around to this again, but I'm still unable to reproduce this.

Is it possible that you have two versions of yaml-cpp installed, and you're 
(e.g.) linking against one but compiling against the other?

Original comment by jbe...@gmail.com on 24 Jan 2015 at 8:53

GoogleCodeExporter commented 9 years ago
I honestly can't say. I've restructured my entire C++ library folder to make 
changing compilers easier. I doubt it though.

Original comment by ARandomFurry on 24 Jan 2015 at 10:38

GoogleCodeExporter commented 9 years ago
So can you still reproduce this issue?

Original comment by jbe...@gmail.com on 24 Jan 2015 at 10:42

GoogleCodeExporter commented 9 years ago
No, it works.

Original comment by ARandomFurry on 25 Jan 2015 at 1:38

GoogleCodeExporter commented 9 years ago
OK, thanks for following up.

Original comment by jbe...@gmail.com on 25 Jan 2015 at 1:40