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

Author Topic: Mono and SFML.net  (Read 10166 times)

0 Members and 1 Guest are viewing this topic.

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Mono and SFML.net
« on: July 21, 2014, 10:00:26 pm »
So there are already a tonne of posts about this, but I'm not sure what to do next because no one else has quite had this issue.

First, SFML/CSFML are compiled from source and are in the /usr/local/lib directory.
Second, copying the c++ SFML code from the linux example and compiling works.
Third, I have all the SFMLnet dlls in the same directory as my exe.
Fourth, I have all the configmaps for DLL's in the same directory as my exe AND my source.
Fifth, my code only opens a window. It's literally just the RenderWindow and loop code.
Lastly, the error it's giving me is a Segmentation Fault : http://pastebin.com/0JLWchRX

My boss says it's unicode error but I don't think so. Is there anything obvious I'm doing wrong? It's Mint 15, 64 bit. I've compiled SFML.net's dlls for both 32, while 64 bit fails to compile.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Mono and SFML.net
« Reply #1 on: July 21, 2014, 10:09:48 pm »
I'm no .net expert, that's for sure. But a segfault means you tried to access memory outside your processes allocated address space.  That usually means you dereferenced a null pointer, have a use-after-free bug or dereferenced some uninitialized pointer (that could point anywhere).
Personally I'd start by looking for uninitialized pointer variables, pointers that are not checked for null before use, check that objects are not going out of scope while still being referenced etc.
Tools like address-sanitizer and Valgrind may also help pinpoint the problem quickly.
Just my $0.02

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Mono and SFML.net
« Reply #2 on: July 21, 2014, 10:15:11 pm »
Quote
My boss says it's unicode error but I don't think so
Indeed it's probably not. Just because the name of the function contains "Unicode" doesn't mean that any crash in this function is caused by Unicode problems (and anyway, what does "Unicode error" mean?). sfRenderWindow_createUnicode is just the name of the RenderWindow constructor that is called by SFML.Net.

Since it's the first function that is called by your code, it's most likely an environment error. Calling any other function would probably result in the same kind of error, just in another C function.

Quote
It's Mint 15, 64 bit. I've compiled SFML.net's dlls for both 32, while 64 bit fails to compile.
Are you sure that everything is compiled for 32-bits then (SFML, CSFML, SFML.Net)? A mix between architectures could result in such a segfault.

Quote
I'm no .net expert, that's for sure. But a segfault means you tried to access memory outside your processes allocated address space.  That usually means you dereferenced a null pointer, have a use-after-free bug or dereferenced some uninitialized pointer (that could point anywhere).
Personally I'd start by looking for uninitialized pointer variables, pointers that are not checked for null before use, check that objects are not going out of scope while still being referenced etc.
Tools like address-sanitizer and Valgrind may also help pinpoint the problem quickly.
This kind of problems are very unlikely to happen in a managed environment ;)
Even using a null pointer would result in a NullPointerException C# exception, not a segfault in the C API.
Laurent Gomila - SFML developer

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Mono and SFML.net
« Reply #3 on: July 21, 2014, 10:23:26 pm »
> Are you sure that everything is compiled for 32-bits then (SFML, CSFML, SFML.Net)? A mix between architectures could result in such a segfault.


That is my thought as well. Is there a way to check how SFML/CSFML were compiled? SFML.Net I can assure you is 32 bits, but I just did a git clone on the SFML/CSFML repos, used cmake-gui to build them and sudo make, then sudo make install to install them. I didn't see bit-options.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Mono and SFML.net
« Reply #4 on: July 21, 2014, 10:30:58 pm »
You can use 'file' command to see what exactly is each .so, including bitness.
Back to C++ gamedev with SFML in May 2023

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Mono and SFML.net
« Reply #5 on: July 21, 2014, 10:36:49 pm »
The 'readelf' and 'objdump' tools can also often be useful :)

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Mono and SFML.net
« Reply #6 on: July 21, 2014, 10:41:04 pm »
Certainly, all the .so's are 64 bit.

So I should either figure out why sfml.net won't compiled to 64 bit ("Could not write to file 'sfmlnet-system-2', cause: AMD64) or figure out how to compile all the CSFML/SFML stuff to 32... hrm

Strelok

  • Full Member
  • ***
  • Posts: 139
    • View Profile
    • GitHub
Re: Mono and SFML.net
« Reply #7 on: July 21, 2014, 10:43:55 pm »
Cmake gives you the choice for creating either a normal solution or a 64bit solution if i recall correctly

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Mono and SFML.net
« Reply #8 on: July 22, 2014, 07:42:41 am »
Quote
Cmake gives you the choice for creating either a normal solution or a 64bit solution if i recall correctly
That's for IDEs that support both... mainly Visual Studio. On Linux you must have the whole 32-bits toolchain and dependencies, which can be a lot to install.

You'd better figure out how to compile SFML.Net for 64-bits. When does this error happen? Is it all that is printed?
Laurent Gomila - SFML developer

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Mono and SFML.net
« Reply #9 on: July 22, 2014, 02:56:09 pm »
Quote
Cmake gives you the choice for creating either a normal solution or a 64bit solution if i recall correctly
That's for IDEs that support both... mainly Visual Studio. On Linux you must have the whole 32-bits toolchain and dependencies, which can be a lot to install.

You'd better figure out how to compile SFML.Net for 64-bits. When does this error happen? Is it all that is printed?

Yeah, that's all that is printed. A quick google (before my morning coffee mind you) has brought up that my dependency might be 32 bit, but when I did a file on libcsfml-system.so.2.1 it says 64 bit... hrm. Head scratcher.

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Mono and SFML.net
« Reply #10 on: July 22, 2014, 04:40:00 pm »
Update:

Compiling for "Any CPU" does not solve the issue.

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Mono and SFML.net
« Reply #11 on: July 22, 2014, 04:52:18 pm »
Compiled for 64 bit on Windows and moved it over (which is fine, the .net framework allows that). Same error and I can confirm that they are 64 bit dll's now using the file command in linux.

Same segmentation fault. I'm at a loss as to how so many people can get this working without issue and I've been struggling for 10 days between IRC and the forums, and still not any further in on this.

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Mono and SFML.net
« Reply #12 on: July 23, 2014, 04:42:32 pm »
Looks like the only solution I have is to enforce 32 bits by partitioning a new 32 bit linux install and starting from scratch. Laurent, I'll leave the 64 bit installation in case you come up with any other ideas.

It's disappointing that there is this confusing limitation, but I suppose that's the nature of using a C# wrapper of a C wrapper of a C++ program, in Mono.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Mono and SFML.net
« Reply #13 on: July 23, 2014, 05:03:47 pm »
For the record, I am using 32bit SFML.NET libs on Ubuntu 64bit without any issues. Sorry I really can't help you anymore.  :P
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

FallenWyvern

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Mono and SFML.net
« Reply #14 on: July 24, 2014, 03:17:18 pm »
For the record, I am using 32bit SFML.NET libs on Ubuntu 64bit without any issues. Sorry I really can't help you anymore.  :P

I appreciate it. My bosses asked me to look into transitions between sprites so I'm doing that now, maybe once I get back to it I'll dig deeper.

 

anything