Author Topic: Patch: fix segfault on startup when fonts aren't found  (Read 2029 times)

0 Members and 1 Guest are viewing this topic.

Offline ArthurDenture

Patch: fix segfault on startup when fonts aren't found
« on: March 31, 2013, 07:54:08 PM »
This is just a small side effect of my work trying to port to SDL2. I noticed a segfault when trying to run from a directory that didn't have the full set of support files. Anyhow, it was simply due to a return code not being checked. The attached patch turns the segfault into a clean exit with an error.


The patch was produced with git but should apply cleanly at svn revision 6423.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8823
  • Total likes: 323
  • Helpful: 229
  • Languages: De,EN,JP
Re: Patch: fix segfault on startup when fonts aren't found
« Reply #1 on: March 31, 2013, 10:48:14 PM »
Printing to stderr will not show the message on windows ... Thanks

Offline ArthurDenture

Re: Patch: fix segfault on startup when fonts aren't found
« Reply #2 on: March 31, 2013, 10:50:53 PM »
Should I use dbg->error() instead? What's preferred? I see a variety of ways of printing error messages in the source code.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8823
  • Total likes: 323
  • Helpful: 229
  • Languages: De,EN,JP
Re: Patch: fix segfault on startup when fonts aren't found
« Reply #3 on: March 31, 2013, 10:51:52 PM »
The dbg subsystem may not be initialized such early on. I need to check this.

Offline ArthurDenture

Re: Patch: fix segfault on startup when fonts aren't found
« Reply #4 on: April 06, 2013, 01:59:07 PM »
I was going to go check this out further, but it seems this was accepted as r6427, thanks. :-)

(Fwiw, I do see that simgraph_init is for sure preceded by logging setup. No idea what happens on Windows w.r.t. printing to stderr, though.)

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4870
  • Total likes: 202
  • Helpful: 108
  • Languages: EN, NO
Re: Patch: fix segfault on startup when fonts aren't found
« Reply #5 on: April 06, 2013, 02:12:26 PM »
(Fwiw, I do see that simgraph_init is for sure preceded by logging setup. No idea what happens on Windows w.r.t. printing to stderr, though.)

I think it's pretty much the same as with simutrans 2> /dev/null on *nix.