Segfault when running Twinklebear's basic tutorial code |
Murenius
|
I'm awfully sorry about forgetting the closing code bracket, and it seems I can't edit my post. Sorry again!
|
|||||||||||
|
Murenius
|
May I ask if this is something where nobody can help or is my question just plain stupid or inadequate? I'm at a loss about how to solve this and would do extensive reading or research if someone could give me a hint what to check or do.
|
|||||||||||
|
Naith
|
I copy-pasted your code into a project of my own and tried to execute it. Everything went fine, the texture is being rendered in the window without any crash and the program turns off itself after 3 seconds.
Check that the image is in the correct directory (i.e, that it is being found by SDL during startup of the program) and that it isn't damaged/corrupt in some way. Also check your SDL linker settings and re-download SDL from official website if the crashing remains. Also, make a new bmp file and try to use that instead. |
|||||||||||
|
Murenius
|
Thanks a lot for that info! The image is correct and in the right directory, I tried several images and resaved it to make sure it's a 24bit bmp. So that's not the reason - it doesn't crash in the SDL_loadBMP line. It crashes when trying to convert the surface to a texture.
But the most important point is that it ran just fine for you. I'll try to compile and run it on another machine. So far I tried it in a Linux VM under Mac OS X. I'll try it on native linux on my desktop pc at home. If it works the problem might be the gfx card drivers or the problems with 3d accelleration in a VM. Didn't think this could cause a problem. |
|||||||||||
|
MrTAToad
|
Using nullptr may not be correct as it may have a value other than NULL/0
|
|||||||||||
|
Segfault when running Twinklebear's basic tutorial code |
MrOzBarry
|
To cover all the bases, how are you building (ie toolchain, IDE, etc.) and running this (from IDE, terminal, etc.)?
On Mon, Jun 8, 2015 at 11:02 AM, Murenius wrote:
|
|||||||||||||
|
MrTAToad
|
And debug or release mode ?
|
|||||||||||
|
Murenius
|
I'm working in an Ubuntu VM with 14.04, running on VMware on a Macbook Pro. This is a company PC and I'm allowed to run VMs on it, so that's why. At home I have a desktop with native Linux, I just want to work on the project while I am on the train or in the hotel.
I'm using Code::Blocks as IDE and use gcc/g++ as compiler. So far I've only compiled and run everything in debug mode, so I have symbols when debugging. Thanks for the hint with nullptr, I'm not too familiar with all the c++11 novelties. Against what should I compare instead? If it's not null/0 can I somehow check if the returned memory address is right? I haven't manually dealt with memory allocation systematics so far. To make everything a bit weirder, I tried to compile and run Lazy Foo's tutorial in the VM and it runs without a segfault. So the call to SDL_surfacetotexture is not generally the problem... Thanks and regards |
|||||||||||
|
Segfault when running Twinklebear's basic tutorial code |
Daniel Gibson
Guest
|
On 06/08/2015 11:12 PM, Murenius wrote:
Running it in a VM may cause problems, because textures are hardware-accelerated (on the GPU) and you might not have working OpenGL acceleration in your VM.
I guess nullptr shouldn't be a problem in practice, even if the standard may allow it not to be 0 (no idea if that's indeed the case).
No idea about that part. Cheers, Daniel _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||
|
Murenius
|
I just checked the hardware acceleration and it works, shouldn't be a problem. Please see the following output. Also, glxgears runs smoothly and hardware accelerated.
I'm still at a loss finding the problem. My current understanding is: I use the SDL_surfacetotexture() function and both parameters are not nullpointers. My guess is that one of the memory addresses in the parameters for this is restricted memory. Can someone tell me how I can find this out or analyze further? |
|||||||||||||
|
MrTAToad
|
Virtual Machines may not actually be telling the truth - whilst it may report acceleration, the truth may be rather different
Do you have a proper Linux machine to hand ? If so, it may be worth testing that too. It may be worth changing == nullptr to == NULL, just in case there is a problem there. I do know that the gcc version isn't up to par with the Visual Studio version (unless you compile the latest version yourself) - which should hopefully change with 2.0.4 - so, if you could, try it with Visual Studio |
|||||||||||
|