When I place a breakpoint inside it (exactly before the SIGSEGV segmentation fault occurs) I can see that the address of itr = 0x0. A NULL POINTER AAARGH
I wouldn't always trust the debugger unconditionally (are you compiling with optimizations enabled?).
Does an assert(*itr) before the call get triggered?
What does update() do? Can it remove the element from the list?
Well, "array" is representative for all sorts of containers.
Dereferencing other invalid pointers or iterators can do it too. What happens if you enable debug iterators? Or are they already enabled?
EDIT: now I'm getting segmentation faults ON the assert :s
Well, that's getting a bit strange. What happens when you print &itr and *itr every iteration?
You might want to look at the generated assembler code and the exact instruction that triggers the segmentation fault too.
Ok I tried printing them, but it doesn't output anything.
std::cout seems to have stopped working, for example my std::cout statement in the contructor of my class doesn't output either :s
Perhaps you started it from the wrong working directory (if you use relative paths for loading resources)?
Does valgrind already print any warnings until that point?
Invalid read of size 8
==5012== at 0x4135AB: Level::update(int) (Level.cpp:145)
==5012== by 0x40C8AE: GameState::update() (GameState.cpp:42)
==5012== by 0x5AA58A8: sfge::StateManager::update() (StateManager.cpp:60)
==5012== by 0x40BC5B: Game::run() (Game.cpp:29)
==5012== by 0x417D07: main (main.cpp:10)
==5012== Address 0x7803f800010 is not stack'd, malloc'd or (recently) free'd
==5012==
==5012==
==5012== Process terminating with default action of signal 11 (SIGSEGV)
==5012== Access not within mapped region at address 0x7803F800010
==5012== at 0x4135AB: Level::update(int) (Level.cpp:145)
==5012== by 0x40C8AE: GameState::update() (GameState.cpp:42)
==5012== by 0x5AA58A8: sfge::StateManager::update() (StateManager.cpp:60)
==5012== by 0x40BC5B: Game::run() (Game.cpp:29)
==5012== by 0x417D07: main (main.cpp:10)
==5012== If you believe this happened as a result of a stack
==5012== overflow in your program's main thread (unlikely but
==5012== possible), you can try to increase the size of the
==5012== main thread stack using the --main-stacksize= flag.
==5012== The main thread stack size used in this run was 8388608.
uccesfully loaded in32 brick==5012==
That's exactly where the segmentation fault occurs.
What does it add to what we know already?