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

Author Topic: sf::IpAddress::getPublicAddress().toString() crash!  (Read 5530 times)

0 Members and 2 Guests are viewing this topic.

Mars_999

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« on: March 18, 2012, 12:36:59 pm »
I don't even get a call stack.... but using toInteger() works fine?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #1 on: March 18, 2012, 04:56:12 pm »
First:
Dude why are you spaming the link to this thread on other threads? :shock:
Do you know what the netiquettes are for forums? :roll:

Second:
I'm surprised you could even post such a short message...
Show us a complete minimal example. Give us the specific error you get or what happens, rather than telling us what doesn't happen.
Also which platform and compiler you're using.

You see even my post got longer than yours...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mars_999

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #2 on: March 18, 2012, 05:01:31 pm »
Quote from: "eXpl0it3r"
First:
Dude why are you spaming the link to this thread on other threads? :shock:
Do you know what the netiquettes are for forums? :roll:

Second:
I'm surprised you could even post such a short message...
Show us a complete minimal example. Give us the specific error you get or what happens, rather than telling us what you doesn't happen.
Also which platform and compiler.

You see even my post got longer than yours...


First off that other link was to hopefully bring attention before SFML2.0 is released if this indeed is an issue...

second just call it

std::cout << sf::IpAddress::getPublicAddress().toString() << std::endl;

simple as that after SFML is setup not rocket science

and this is the whole call stack dump

>   ntdll.dll!774e04e4()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]   
    ntdll.dll!774a2a2a()    
    ntdll.dll!77471cd7()    
    ntdll.dll!77449ec5()

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #3 on: March 18, 2012, 05:07:48 pm »
Quote
Code: [Select]
std::cout << sf::IpAddress::getPublicAddress().toString() << std::endl;

Works for me.

Is it getPublicAddress() or toString() which crashes? Why can't you get a call stack when debugging, are you running in release mode or without the debug symbols?

Please give more information, read this carefully:
http://www.sfml-dev.org/forum/viewtopic.php?t=5559
Laurent Gomila - SFML developer

Mars_999

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #4 on: March 18, 2012, 05:10:27 pm »
Quote from: "Laurent"
Quote
Code: [Select]
std::cout << sf::IpAddress::getPublicAddress().toString() << std::endl;

Works for me.

Is it getPublicAddress() or toString() which crashes? Why can't you get a call stack when debugging, are you running in release mode or without the debug symbols?

Please give more information, read this carefully:
http://www.sfml-dev.org/forum/viewtopic.php?t=5559


I am running debug, and have no idea why....

But if I do this
sf::IpAddress ip = sf::IpAddress::getPublicAddress();

no crash

this crashes
sf::IpAddress ip = sf::IpAddress::getPublicAddress();
std::cout << ip.toString() << std::endl;

Popup says
This may be due to a corruption of the heap...

or F12 being pressed? Odd no keys are being pressed.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #5 on: March 18, 2012, 05:12:02 pm »
Does it crash with any IP address? (try None, LocalHost, Broadcast, getLocalAddress(), ...)

Did you enable the STATIC_STD_LIBS CMake option when building SFML?

And please, follow the link I gave you above, read carefully and give us more details (version of SFML, compiler, OS, your build options, ...)
Laurent Gomila - SFML developer

Mars_999

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #6 on: March 18, 2012, 05:13:33 pm »
I think I got the call stack


>   msvcr100d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse)  Line 1322 + 0x30 bytes   C++
    msvcr100d.dll!_free_dbg(void * pUserData, int nBlockUse)  Line 1265 + 0xd bytes   C++
    msvcr100d.dll!operator delete(void * pUserData)  Line 54 + 0x10 bytes   C++
    CosmosExpedition.exe!std::allocator<std::_Container_proxy>::deallocate(std::_Container_proxy * _Ptr, unsigned int __formal)  Line 182 + 0x9 bytes   C++
    CosmosExpedition.exe!std::_String_val<char,std::allocator<char> >::~_String_val<char,std::allocator<char> >()  Line 481   C++
    CosmosExpedition.exe!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::~basic_string<char,std::char_traits<char>,std::allocator<char> >()  Line 754 + 0xf bytes   C++
    CosmosExpedition.exe!NX::App::Run()  Line 18   C++
    CosmosExpedition.exe!main(int argc, char * * argv)  Line 14   C++
    CosmosExpedition.exe!__tmainCRTStartup()  Line 555 + 0x19 bytes   C
    CosmosExpedition.exe!mainCRTStartup()  Line 371   C
    kernel32.dll!75be339a()    
    [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]   
    ntdll.dll!77449ef2()    
    ntdll.dll!77449ec5()

Mars_999

  • Full Member
  • ***
  • Posts: 103
    • View Profile
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #7 on: March 18, 2012, 05:21:11 pm »
ARGH!!!!!!!!!!!! Static bindings was the issue... :(  :oops:

BTW why would that cause that one function to crash anyway?

Thanks!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #8 on: March 18, 2012, 05:53:17 pm »
Quote
Static bindings

I assume you're talking about the STATIC_STD_LIBS option.

What happens is that you end up with two versions of the standard library: one is the static one (because of this option), which is included directly inside the SFML libraries, and the other is the dynamic one, which is used by your application (because you didn't apply the same option to your own project).

The string is created by SFML, so it is allocated in the static standard library, but it is destroyed in your app, so the memory is released in the dynamic standard library. Result: allocation and deallocation happen in two different modules, boom.

Never ever play with STATIC_STD_LIBS unless you know what you do.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #9 on: March 18, 2012, 06:04:55 pm »
Quote from: "Laurent"
Never ever play with STATIC_STD_LIBS unless you know what you do.


Or always use STATIC_STD_LIBS for every project. run and hide  :lol:
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::IpAddress::getPublicAddress().toString() crash!
« Reply #10 on: March 18, 2012, 06:06:27 pm »
Quote
Or always use STATIC_STD_LIBS for every project.

He might not know which Visual Studio option STATIC_STD_LIBS translates to ;)
That's why I said that you must know what you do if you turn it on.
Laurent Gomila - SFML developer