Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Thor+SaveGLStates Segmentation Fault!  (Read 4750 times)

0 Members and 1 Guest are viewing this topic.

Haikarainen

  • Guest
Thor+SaveGLStates Segmentation Fault!
« on: July 01, 2011, 09:00:05 am »
I know this is an issue brought up using the Thor library, but it traces back right in to the SFML library itself, thats why I'm posting it here.

So, I recently experienced some trouble trying to run a simple example using SFML And Thor for particles,

Sourcecode for example:
https://legacy.sfmluploads.org/index.php?page=view_code&id=40.

This results in a Segmentationfault, stacktrace follows:
Code: [Select]
#0 68EDD558 sf::RenderTarget::SaveGLStates(this=0x22e8d0) (C:\Program\CodeBlocks\Libraries\SFML2\src\SFML\Graphics\RenderTarget.cpp:185)
#1 0049661C thor::ParticleSystem::PushOpenGLStates(this=0x22fe94, target=@0x22e578) (C:\Users\Jan\C++\Thor\src\ParticleSystem.cpp:111)
#2 00496556 thor::ParticleSystem::Draw(this=0x22fe94, target=@0x22e578) (C:\Users\Jan\C++\Thor\src\ParticleSystem.cpp:111)
#3 00401997 main() (E:\work\c++\crap\crap001\main.cpp:28)


I've traced the files myself;
#1 from stacktrace is on line 250 of ParticleSystem.cpp(Thor);
Code: [Select]
void ParticleSystem::PushOpenGLStates(sf::RenderWindow& target) const
{
// Switch to manual OpenGL handling, save SFML's state
target.SaveGLStates(); <--- THIS LINE
target.SetActive();


#0 from stacktrace is on line 285 of RenderTarget.cpp(SFML);
Code: [Select]
void RenderTarget::SaveGLStates()
{
    if (Activate(true)) <--- THIS LINE
    {
        myRenderer.SaveGLStates();
        myStatesSaved = true;


As you can see, it all starts at line 28 of main.cpp (#3 in call stack), where the System.Draw(Wnd) is called.

My system consists of AMDx86, Windows XPSP3, Latest Codeblocks w/ MinGW, Latest SFML Snapshot, Thor 1.0.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor+SaveGLStates Segmentation Fault!
« Reply #1 on: July 01, 2011, 09:32:57 am »
Quote from: "Haikarainen"
My system consists of AMDx86, Windows XPSP3, Latest Codeblocks w/ MinGW, Latest SFML Snapshot, Thor 1.0.
Could you try the SVN version of Thor? I don't think Thor 1.0 is compatible with the latest SFML Git revision, some things like sf::Clock have changed in the meantime.

In case the problem persists: Does the Thor Particles example work? Do you manage to create a minimal example that reproduces the crash?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Haikarainen

  • Guest
Re: Thor+SaveGLStates Segmentation Fault!
« Reply #2 on: July 01, 2011, 09:37:40 am »
Quote from: "Nexus"
Quote from: "Haikarainen"
My system consists of AMDx86, Windows XPSP3, Latest Codeblocks w/ MinGW, Latest SFML Snapshot, Thor 1.0.
Could you try the SVN version of Thor? I don't think Thor 1.0 is compatible with the latest SFML Git revision, some things like sf::Clock have changed in the meantime.

In case the problem persists: Does the Thor Particles example work? Do you manage to create a minimal example that reproduces the crash?


I will get right on that, just gotta install subversion. Also, if the example i provided wasnt minimal enough, please inform me exactly how you mean :P

EDIT: I'm having some trouble with cmake, the svn version of thor, and the latest sfml2 snapshot. cmake returns:
Code: [Select]
CMake Warning at CMakeLists.txt:86 (find_package):
  Could not find module FindSFML.cmake or a configuration file for package
  SFML.

  Adjust CMAKE_MODULE_PATH to find FindSFML.cmake or set SFML_DIR to the
  directory containing a CMake configuration file for SFML.  The file will
  have one of the following names:

    SFMLConfig.cmake
    sfml-config.cmake



CMake Error at CMakeLists.txt:92 (message):
  SFML directory not found.  Set SFMLDIR to SFML's top-level path (containing
  "include" and "lib" directories).


Configuring incomplete, errors occurred!


I've set SFMLDIR correctly, made sure include and lib is there, just one thing: I do not have an SFMLConfig.cmake file, i do have a Config.cmake in the ./cmake dir, and i tried copying it to SFMLConfig.cmake, but then i got:
Code: [Select]
CMake Warning at CMakeLists.txt:86 (find_package):
  Could not find a configuration file for package "SFML" that is compatible
  with requested version "2".

  The following configuration files were considered but not accepted:

    C:/Program/CodeBlocks/Libraries/SFML2/SFMLConfig.cmake, version: unknown



CMake Error at CMakeLists.txt:92 (message):
  SFML directory not found.  Set SFMLDIR to SFML's top-level path (containing
  "include" and "lib" directories).


Configuring incomplete, errors occurred!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor+SaveGLStates Segmentation Fault!
« Reply #3 on: July 01, 2011, 10:06:01 am »
Quote from: "Haikarainen"
Also, if the example i provided wasnt minimal enough, please inform me exactly how you mean :P
Sorry, I didn't see it. Note that with the new SFML version, you need to divide GetFrameTime() by 1000.f, because SFML returns milliseconds. I've changed the code accordingly. And as you don't move the emitter, the particle system will just emit particles in the left-upper corner. But the code works at me :)

By the way, is there a possibility to copy the code without having to click "Create a new version of this code"? If I mark it and insert it into Visual Studio, the line breaks aren't recognized, and the line numbers are also copied.

Quote from: "Haikarainen"
EDIT: I'm having some trouble with cmake, the svn version of thor, and the latest sfml2 snapshot. cmake returns:
Hm, that's strange. Normally, CMake should find SFML automatically or at least if you specify the SFML directory.

Can you check if the path C:\Program Files\CMake 2.8\share\cmake-2.8\Modules (or similar) contains a file named FindSFML.cmake? If it isn't there, compile the CMake INSTALL project of SFML, it should copy the FindSFML module into that folder (make install could be a good idea anyway).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Haikarainen

  • Guest
Re: Thor+SaveGLStates Segmentation Fault!
« Reply #4 on: July 01, 2011, 10:14:35 am »
Quote from: "Nexus"
Sorry, I didn't see it. Note that with the new SFML version, you need to divide GetFrameTime() by 1000.f, because SFML returns milliseconds. I've changed the code accordingly. And as you don't move the emitter, the particle system will just emit particles in the left-upper corner. But the code works at me :)

By the way, is there a possibility to copy the code without having to click "Create a new version of this code"? If I mark it and insert it into Visual Studio, the line breaks aren't recognized, and the line numbers are also copied.

Hm, that's strange. Normally, CMake should find SFML automatically or at least if you specify the SFML directory.

Can you check if the path C:\Program Files\CMake 2.8\share\cmake-2.8\Modules (or similar) contains a file named FindSFML.cmake? If it isn't there, compile the CMake INSTALL project of SFML, it should copy the FindSFML module into that folder (make install could be a good idea anyway).


Oh right, forgot that. Didn't make a difference tho. Thats weird, what browser are you using? I can copy the code just fine using Firefox 5 and Codeblocks.

It has the FindSFML file, actually ,i have the exact same files that's in https://github.com/SFML/SFML/tarball/master, except i've built both debug and release libs, and copied the libdir from the build-dir to the rootdir, so it shouldnt really be a problem.

You dont happen to have win32-binaries+includes of the latest binary in a zipfile to send, to see if it resolves the mainproblem? Then we could get on cmaking it.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor+SaveGLStates Segmentation Fault!
« Reply #5 on: July 01, 2011, 10:33:51 am »
Quote from: "Haikarainen"
Oh right, forgot that. Didn't make a difference tho. Thats weird, what browser are you using? I can copy the code just fine using Firefox 5 and Codeblocks.
Internet Explorer 9 :P

Quote from: "Haikarainen"
It has the FindSFML file, actually ,i have the exact same files that's in https://github.com/SFML/SFML/tarball/master
But is FindSFML.cmake also in the CMake modules directory, not only in SFML's folder cloned from Git?

Quote from: "Haikarainen"
You dont happen to have win32-binaries+includes of the latest binary in a zipfile to send, to see if it resolves the mainproblem? Then we could get on cmaking it.
I can compile  and send it, what configurations do you need? Is
Code: [Select]
MinGW
- Release
- Link SFML dynamically
- Link standard library dynamically
okay? Do you have the newest Git revision of SFML?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Haikarainen

  • Guest
Re: Thor+SaveGLStates Segmentation Fault!
« Reply #6 on: July 01, 2011, 10:39:17 am »
Quote from: "Nexus"
Quote from: "Haikarainen"
Oh right, forgot that. Didn't make a difference tho. Thats weird, what browser are you using? I can copy the code just fine using Firefox 5 and Codeblocks.
Internet Explorer 9 :P

Quote from: "Haikarainen"
It has the FindSFML file, actually ,i have the exact same files that's in https://github.com/SFML/SFML/tarball/master
But is FindSFML.cmake also in the CMake modules directory, not only in SFML's folder cloned from Git?

Quote from: "Haikarainen"
You dont happen to have win32-binaries+includes of the latest binary in a zipfile to send, to see if it resolves the mainproblem? Then we could get on cmaking it.
I can compile  and send it, what configurations do you need? Is
Code: [Select]
MinGW
- Release
- Link SFML dynamically
- Link standard library dynamically
okay? Do you have the newest Git revision of SFML?


Yup, Yup. ^^

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Thor+SaveGLStates Segmentation Fault!
« Reply #7 on: July 01, 2011, 11:04:52 am »
Okay, I sent you an e-mail. I used .7z instead of .zip archives, because GMail complained about the exe files inside the archive :?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Haikarainen

  • Guest
Thor+SaveGLStates Segmentation Fault!
« Reply #8 on: July 02, 2011, 04:48:59 am »
Quote from: "Nexus"
Okay, I sent you an e-mail. I used .7z instead of .zip archives, because GMail complained about the exe files inside the archive :?


Got them, your precompiled are working like a charm, no luck with building the lib myself tho :/

I really have to say, your particlesystem is COOL stuff!
Played around with it  alot, created a really cool fire & smokething. sadly i did it while playing around with a project of mine, so the files are pretty heavy..:

https://legacy.sfmluploads.org/index.php?page=view_file&file_id=26

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Thor+SaveGLStates Segmentation Fault!
« Reply #9 on: July 02, 2011, 08:52:50 am »
Quote from: "Haikarainen"
Got them, your precompiled are working like a charm, no luck with building the lib myself tho :/
Maybe it helps if you clean up all the SFML, CMake and Thor stuff and try to reinstall everything from scratch... At least it looks like some configurations are upset. However I have never had exactly this issue (but a few others where reinstalling everything solved the problem).

By the way, why do you have "sfml-system.dll" etc. while my compiled SFML binaries are of the form "sfml-system-2.dll"? Are you working with an older SFML revision?

Quote from: "Haikarainen"
Played around with it  alot, created a really cool fire & smokething.
The fire/smoke effect looks really nice, I didn't know my particle system would be able to do that :D
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Haikarainen

  • Guest
Thor+SaveGLStates Segmentation Fault!
« Reply #10 on: July 02, 2011, 09:35:09 am »
Quote from: "Nexus"
Maybe it helps if you clean up all the SFML, CMake and Thor stuff and try to reinstall everything from scratch... At least it looks like some configurations are upset. However I have never had exactly this issue (but a few others where reinstalling everything solved the problem).


Will try this later, looks like i have a lot to cleanup actually.

Quote from: "Nexus"
By the way, why do you have "sfml-system.dll" etc. while my compiled SFML binaries are of the form "sfml-system-2.dll"? Are you working with an older SFML revision?


Thats dangerously weird, must've forgot to replace the sfml-binaries in the releasefolder, it's based on an old, restored project of mine.  Thanks for the headsup :D

Also, I'm working with latest SFML, the only thing that wasnt latest was the binaries in the releasefolder of this project ,everything else is uptodate, including my attempts to configure thor-cmake

Quote from: "Nexus"
The fire/smoke effect looks really nice, I didn't know my particle system would be able to do that :D


Thanks ^^ I could move them to a new clean showcase-project if you'd want it for PR/demos? Also begun with a waterfall but didn't manage to get it  to look just as nice.

Btw: Can triangulate be used as emitterzones? Have an idea for spreadable fire but dont really know what the best approach would be.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Thor+SaveGLStates Segmentation Fault!
« Reply #11 on: July 02, 2011, 10:18:39 am »
Quote from: "Haikarainen"
Thanks ^^ I could move them to a new clean showcase-project if you'd want it for PR/demos?
That's a good idea, thank you. But don't waste hours just to make a cool effect :)

Quote from: "Haikarainen"
Btw: Can triangulate be used as emitterzones? Have an idea for spreadable fire but dont really know what the best approach would be.
What do you mean exactly? In principle, you can pass any class derived from thor::Zone as emission zone. Just override the GetRandomPoint() method.

You can also take a thor::Circle and continuously increase its radius. Maybe I should allow to scale thor::Zone objects directly by inheriting the class from thor::Scalable...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Haikarainen

  • Guest
Thor+SaveGLStates Segmentation Fault!
« Reply #12 on: July 02, 2011, 10:32:42 am »
Quote from: "Nexus"
That's a good idea, thank you. But don't waste hours just to make a cool effect :)


Hehe I will notice you when i got time to do it :) Didn't take too long to create them tho, just had to come up with the right .png's and tweak it.

Quote from: "Nexus"
What do you mean exactly? In principle, you can pass any class derived from thor::Zone as emission zone. Just override the GetRandomPoint() method.


Cool thanks! Just what i needed :D

 

anything