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

Author Topic: SIGSEGV on drawing  (Read 2175 times)

0 Members and 1 Guest are viewing this topic.

Grox2006

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
SIGSEGV on drawing
« on: July 05, 2016, 11:44:12 pm »
Hello everyone,
I've been using SFML from quite a bit now and decided to switch to the DotNet version. I'm working on Ubuntu 14 (extended Chromebook) as I'm on a trip (and don't have access to my Windows setup).

I created a little game architecture which worked quite well, until I decided to draw a drawable.
Whenever I try to draw something, I get this error :

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) SFML.Graphics.Sprite.sfRenderWindow_drawSprite (intptr,intptr,SFML.Graphics.RenderStates/MarshalData&) <IL 0x00011, 0xffffffff>
  at SFML.Graphics.Sprite.Draw (SFML.Graphics.RenderTarget,SFML.Graphics.RenderStates) <IL 0x00040, 0x002d3>
  at SFML.Graphics.RenderWindow.Draw (SFML.Graphics.Drawable,SFML.Graphics.RenderStates) <IL 0x00004, 0x000e2>
  at SFML.Graphics.RenderWindow.Draw (SFML.Graphics.Drawable) <IL 0x00008, 0x000d3>
  at ProjectEmpyrea.Game.Run () [0x000ab] in /[URL]/Game.cs:50
  at ProjectEmpyrea.MainClass.Main (string[]) [0x00100] in /[URL]/Program.cs:37
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

        /usr/bin/mono() [0x4b73d8]
        /usr/bin/mono() [0x50f13b]
        /usr/bin/mono() [0x423d22]
        /lib/x86_64-linux-gnu/libpthread.so.0(+0x10330) [0x7f68bc6df330]
        /usr/lib/x86_64-linux-gnu/libcsfml-graphics.so.2(sfRenderWindow_drawSprite+0xcf) [0x7f68b1b38c9f]
        [0x4043628b]

Debug info from gdb:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No threads.

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

bash: line 1: 21234 Aborted                 (core dumped) /usr/bin/mono --debug --debugger-agent=transport=dt_socket,address=127.0.0.1:54145 "[URL]/bin/Debug/ProjectEmpyrea.exe"
 

[URL] correspong to the solution path.

Here comes the Game.cs :

using System;
using SFML.Graphics;
using SFML.Window;
using SFML.System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;

namespace ProjectEmpyrea
{
    public class Game : RenderWindow
    {
        public const string pathData = "Data/";
        public const string patternKWorld = "*.kworld";
        public const string logLoadindEnvironment = "[Game] Loading environment...";
        public const string logLoadingWorlds = "[Game] Loading worlds.";
        public const string logLoadingWorld = "[Game] Loading world {0}...";
        public const string logExiting = "[Game] Exitting...";
        public const string logOK = " OK !";

        public DirectoryInfo DirectoryData { get; protected set; }

        public Dictionary<uint, World> Worlds { get; protected set; }
        public Dictionary<uint, Texture> Textures { get; protected set; }

        public Game(string title, uint width, uint height) : base(VideoMode.DesktopMode, title)
        {
            Size = new Vector2u(width, height);
            Closed += OnClose;

            Worlds = new Dictionary<uint, World>();
            Textures = new Dictionary<uint, Texture>();
        }

        public void Run()
        {
            LoadEnvironment();
            LoadWorlds();

            World currentWorld = Worlds[0];
            while(IsOpen)
            {
                DispatchEvents();
                Clear();

                foreach (uint tileID in currentWorld.CurrentChunk.Tiles)
                {
                    Tile tile = currentWorld.Tiles[tileID];
                    LoadTexture(tileID, tile.Texture);
                    Draw(new Sprite(Textures[tileID], new IntRect(new Vector2i(40, 40), new Vector2i(16, 16))));

                    /* TODO Debug this library !! */

                    Console.WriteLine(tile.Name);
                }

                Display();
            }
        }

        public void LoadEnvironment()
        {
            Log.Write(logLoadindEnvironment);
            DirectoryInfo directory = new DirectoryInfo(pathData);
            if (directory != null)
            {
                try
                {
                    if (directory.Exists)
                    {
                        DirectoryData = directory;
                    }
                    else
                    {
                        directory.Create();
                    }
                }
                catch(Exception exception)
                {
                    Log.Write(LogResult.Fail);
                    Log.Write(exception);
                }
            }
            Log.Write(LogResult.Ok);
        }

        public void LoadWorlds()
        {
            Log.WriteLine(logLoadingWorlds);
            foreach (FileInfo file in DirectoryData.GetFiles(patternKWorld))
            {
                Log.Write(logLoadingWorld, file.Name);
                try
                {
                    FileStream stream = new FileStream(file.FullName, FileMode.Open);
                    BinaryFormatter formatter = new BinaryFormatter();

                    World world = (World)(formatter.Deserialize(stream));
                    Worlds.Add(world.Id, world);
                }
                catch(Exception exception)
                {
                    Log.Write(LogResult.Fail);
                    Log.Write(exception);
                }
                /*TODO Expand Tiles and display them */
                Log.Write(LogResult.Ok);
            }
        }

        public void LoadTexture(uint id, byte[] texture)
        {
            if(!Textures.ContainsKey(id))
            {
                Textures[id] = new Texture(texture);
            }
        }

        public void OnClose(object sender, EventArgs e)
        {
            Log.Write(logExiting);
            Close();
            Log.Write(LogResult.Ok);
        }
    }
}

 

Line 50 corresponds to :

Draw(new Sprite(Textures[tileID], new IntRect(new Vector2i(40, 40), new Vector2i(16, 16))));

Also, I am using SFML.Net 2.2 64bits.

Thank you very much in advance, I can't continue my project without being able to draw assets.
Respectfully,
Grox2006