project-navigation
Personal tools

Author Topic: Disabling the signal handler  (Read 4693 times)

Offline keybounce

  • Sergeant
  • *****
  • Posts: 330
    • View Profile
Disabling the signal handler
« on: March 20, 2009, 07:18:40 pm »
How can I disable the signal handler for ufo-ai so that the macintosh can actually give the full stack backtrace?

Change gametype to 'Skirmish mode'
Could not find rank 'rifleman'
Could not find rank 'rifleman'
Could not find rank 'rifleman'
Could not find rank 'rifleman'
Could not find rank 'rifleman'
Could not find rank 'rifleman'
Could not find rank 'rifleman'
Could not find rank 'rifleman'
------- Loading game.dylib -------
LoadLibrary (./base/game.dylib)
==== InitGame ====
Map:wilderness  Offset:(0, 0, 0)
wpMins:(128, 118, 0) wpMaxs:(193, 197, 7)
Shifted wpMins:(128, 118, 0) wpMaxs:(193, 197, 7)
Tile bounds: (128, 118, 0) to (193, 197, 7)
Source bounds: (128, 118, 0) to (193, 197, 7)
Done copying data.
0   ufo                                 0x0019b780 Sys_Mkdir + 180
1   ufo                                 0x0019b7f8 Sys_Mkdir + 300
2   libSystem.B.dylib                   0x92f3399c _sigtramp + 68
Wrote keys.cfg
Error: Received signal 11.

That's not very informative.

All I could find was:

Kleiman-ibook:src michael$ egrep signal */*.c
common/net.c:# include <signal.h>
common/net.c:   signal(SIGPIPE, SIG_IGN);

« Last Edit: March 20, 2009, 07:20:45 pm by keybounce »

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: Disabling the signal handler
« Reply #1 on: March 20, 2009, 07:32:05 pm »
I run the game from gdb (on linux), and it can make backtrace.

-geever

Offline keybounce

  • Sergeant
  • *****
  • Posts: 330
    • View Profile
Re: Disabling the signal handler
« Reply #2 on: March 20, 2009, 08:01:13 pm »
Ahh.

I generally run from the disk image. I figure the same way that anyone will run the final program.

Running direct from the command line this time was a bit of an experiment, and plus I didn't want to go through rebuilding the whole thing just for a quick test.

Having to run from gdb just to get information needed to give to the developers? Well, if that's what it takes ...

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Disabling the signal handler
« Reply #3 on: March 21, 2009, 07:38:50 am »
you are talking about the automatically generated stacktrace?

maybe we should deactivate our own stacktrace feature for macos. can you send an example stacktrace from macos please?

Offline keybounce

  • Sergeant
  • *****
  • Posts: 330
    • View Profile
Re: Disabling the signal handler
« Reply #4 on: March 21, 2009, 04:40:19 pm »
Here's a sample from "World of Goo" on loading a custom level into the demo version (which apparently doesn't support custom levels)



[attachment deleted by admin]

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Disabling the signal handler
« Reply #5 on: March 22, 2009, 07:32:32 am »
Code: [Select]
@@ -524,6 +522,8 @@
 #ifdef HAVE_CURSES
  signal(SIGWINCH, Sys_Signal);
 #endif
+ /* apple provides a nice backtrace feature on their own */
+#if !(defined (__APPLE__) || defined (MACOSX))
  signal(SIGHUP, Sys_Signal);
  signal(SIGINT, Sys_Signal);
  signal(SIGQUIT, Sys_Signal);
@@ -532,4 +532,5 @@
  signal(SIGFPE, Sys_Signal);
  signal(SIGSEGV, Sys_Signal);
  signal(SIGTERM, Sys_Signal);
+#endif
 }

Please try this patch and let me know whether that works for you.

Offline keybounce

  • Sergeant
  • *****
  • Posts: 330
    • View Profile
Re: Disabling the signal handler
« Reply #6 on: March 22, 2009, 05:11:48 pm »
Code: [Select]
Kleiman-ibook:unix michael$ pbpaste | patch
missing header for unified diff at line 1 of patch
can't find file to patch at input line 1
Perhaps you should have used the -p or --strip option?
File to patch: unix_main.c       
patching file unix_main.c
Hunk #1 succeeded at 518 (offset -4 lines).
patch unexpectedly ends in middle of line
Hunk #2 FAILED at 528.
1 out of 2 hunks FAILED -- saving rejects to file unix_main.c.rej
Kleiman-ibook:unix michael$

Manually adjusting ...

Here's what I have compared to the trunk:
Code: [Select]
Kleiman-ibook:trunk michael$ svn diff
Index: src/ports/unix/unix_main.c
===================================================================
--- src/ports/unix/unix_main.c (revision 23646)
+++ src/ports/unix/unix_main.c (working copy)
@@ -520,6 +520,8 @@
 #ifdef HAVE_CURSES
  signal(SIGWINCH, Sys_Signal);
 #endif
+ /* apple provides a nice backtrace feature on their own */
+#if !(defined (__APPLE__) || defined (MACOSX))
  signal(SIGHUP, Sys_Signal);
  signal(SIGINT, Sys_Signal);
  signal(SIGQUIT, Sys_Signal);
@@ -528,4 +530,5 @@
  signal(SIGFPE, Sys_Signal);
  signal(SIGSEGV, Sys_Signal);
  signal(SIGTERM, Sys_Signal);
+#endif
 }
Index: build/maps.mk
===================================================================
--- build/maps.mk (revision 23646)
+++ build/maps.mk (working copy)
@@ -32,7 +32,8 @@
 endif
 
 NICE = 19
-UFO2MAPFLAGS = -v 2 -nice $(NICE) -extra -t $(NUMTHREADS)
+# UFO2MAPFLAGS = -v 2 -nice $(NICE) -extra -t $(NUMTHREADS)
+UFO2MAPFLAGS =        -nice $(NICE) -extra -t $(NUMTHREADS)
 FAST_UFO2MAPFLAGS = -v 2 -quant 6 -nice $(NICE) -t $(NUMTHREADS)
 ENTS_UFO2MAPFLAGS = -v 2 -nice $(NICE) -onlyents

Full clean compile, including maps, ...

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Disabling the signal handler
« Reply #7 on: March 22, 2009, 05:24:13 pm »
looks ok - maybe the forum cut the last newline from my patch.

is it working that way? if yes - then i will think about a cleaner way to handle this.