Hello :)

I've got this resource (as in files on the pc) management system, that had been tested but now seems to be malfunctioning.

I've been debugging for way too long now, and I can't figure out the issue.

I'm going to post some of my code first, and then specify the errors afterwards.

Note String is a typedef for std::string;

In my Class.hpp, in the private section, I'm creating my std::map

typedef std::map<String, ResourceGroup*> resourceGroupMap;
resourceGroupMap m_ResourceGroups;

ResourceGroup is a quite small class.

In my Class.cpp, as the first action in a function, I do this

String name = "some-name-here";
resourceGroupMap::iterator it = m_ResourceGroups.find(name);

That line is what starts the trouble!

GDB marks it as a call stack line, and dives into stl_map as the next call stack:

iterator
find(const key_type& __x)
{ return _M_t.find(__x); }

The last line is the next call stack:

iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);

_M_begin is the last call stack:

_Link_type
_M_begin()
{ return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }

The last line is where i get the segmentation fault signal.

I'm really confused with this, as I find it odd that STL encounters a run-time error with such a simple thing as what I'm doing here.

If you need more code, please tell me so :D

I hope someone can assist me in this nutness!

Thanks! ;)

Hello :)

I've got this resource (as in files on the pc) management system, that had been tested but now seems to be malfunctioning.

I've been debugging for way too long now, and I can't figure out the issue.

I'm going to post some of my code first, and then specify the errors afterwards.

Note String is a typedef for std::string;

In my Class.hpp, in the private section, I'm creating my std::map

typedef std::map<String, ResourceGroup*> resourceGroupMap;
resourceGroupMap m_ResourceGroups;

ResourceGroup is a quite small class.

In my Class.cpp, as the first action in a function, I do this

String name = "some-name-here";
resourceGroupMap::iterator it = m_ResourceGroups.find(name);

That line is what starts the trouble!

GDB marks it as a call stack line, and dives into stl_map as the next call stack:

iterator
find(const key_type& __x)
{ return _M_t.find(__x); }

The last line is the next call stack:

iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);

_M_begin is the last call stack:

_Link_type
_M_begin()
{ return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }

The last line is where i get the segmentation fault signal.

I'm really confused with this, as I find it odd that STL encounters a run-time error with such a simple thing as what I'm doing here.

If you need more code, please tell me so :D

I hope someone can assist me in this nutness!

Thanks! ;)

Hours has past and finally my leet debugging skills solves my own problem...

A function that should create a class and return a pointer was simply missing the part where it return the pointer... So i created the class just fine, but then accessed a nullpointer, doh

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.