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

Author Topic: SFML disables error output on exception termination (c++)  (Read 4224 times)

0 Members and 1 Guest are viewing this topic.

Touchebag

  • Newbie
  • *
  • Posts: 2
    • View Profile
SFML disables error output on exception termination (c++)
« on: November 19, 2021, 05:09:17 pm »
I'm running MinGW (MSYS2) and fairly recently (a couple of months I'd guess) I started having a problem where exception output is not printed on termination.

Minimal example:
#include <SFML/Graphics.hpp>

int main() {
    sf::RenderWindow window(sf::VideoMode(1000,1000), "Whatever");
    throw std::invalid_argument("BLARGH");
}
I expect this to output and terminate
terminate called after throwing an instance of 'std::invalid_argument'
  what():  BLARGH

This works just fine on Linux as well as if I run it via explorer (the "This process has stopped responding" popup opens and the exception output is printed in the terminal in the background). Removing the sf::RenderWindow line also fixes the issue. Normal printing to both stdout and stderr is unaffected.

I cant think of anything in particular that has changed within that timeframe. No MSYS/SFML updates.

I realise this may not be an actual SFML issue (I'm looking into things on MinGW forums as well) but since opening an SFML window manages to consistently trigger it I was hoping anyone here might be able to help me figure out what is causing this issue.
« Last Edit: November 19, 2021, 05:11:28 pm by Touchebag »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML disables error output on exception termination (c++)
« Reply #1 on: November 20, 2021, 09:58:51 am »
Not sure why you'd want to get such a message in console or via message box. If exceptions are thrown, you should catch and handle them.
I assume putting a try/catch block around the throw will still allow you to process the exception, correct?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Touchebag

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML disables error output on exception termination (c++)
« Reply #2 on: November 20, 2021, 10:28:01 am »
These are debugging exceptions. The unrecoverable ones you expect to throw when reading invalid data or while developing. Missing input files, invalid data format and such.

Of course I could just put a try/catch around my entire main loop and print but I still want to find out why this happens.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML disables error output on exception termination (c++)
« Reply #3 on: November 20, 2021, 11:17:59 am »
Those should fire just fine, they also aren't normal exceptions.
If you want to reproduce it, you can try and access a pointer to a random address or call std::terminate() yourself.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything