swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SIGSEGV in munged `potential' code


From: Russell Senior
Subject: SIGSEGV in munged `potential' code
Date: 26 Apr 2001 01:21:17 -0700

Using swarm-2.1.1 compiled from source on GNU/Linux, binutils 2.11,
gcc-2.95.3, I am getting segfaults running some code I munged to
compile with swarm-2.1.1.

It is _very_ possible I just screwed up something.

Here is the backtrace, followed by my patch to the `potential' source
code.  The examples from swarmapps-2.1.1 compile and run fine.

  $ gdb .libs/potential 
  GNU gdb 5.0
  Copyright 2000 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.
  There is absolutely no warranty for GDB.  Type "show warranty" for details.
  This GDB was configured as "i686-pc-linux-gnu"...
  (gdb) run
  Starting program: /src/swarm/potential-new/.libs/potential 
  *** event raised for warning: ResourceAvailability
  *** function: tkobjc_setColor(), file: 
/src/swarm-2.1.1/src/tkobjc/internal.m, line: 639
  Problem allocating color #660000.  Switching to virtual colormap.
  *** execution continuing...
  
  Program received signal SIGSEGV, Segmentation fault.
  0x401b9623 in swarm_directory_objc_find (env=0x0, object=0x81029b0)
      at /src/swarm-2.1.1/src/defobj/directory.m:206
  206           ret = avl_find (swarmDirectory->objc_tree, OBJCFINDENTRY 
(object));
  (gdb) bt
  #0  0x401b9623 in swarm_directory_objc_find (env=0x0, object=0x81029b0)
      at /src/swarm-2.1.1/src/defobj/directory.m:206
  #1  0x401b965a in swarm_directory_objc_find_java (env=0x0, object=0x81029b0)
      at /src/swarm-2.1.1/src/defobj/directory.m:215
  #2  0x401aaebc in _i_Object_s__forward__ (self=0x81029b0, _cmd=0x805dde0, 
      aSel=0x804d0c8, argFrame=0xbfffdd4c)
      at /src/swarm-2.1.1/src/defobj/DefObject.m:605
  #3  0x40233211 in __objc_forward (object=0x81029b0, sel=0x804d0c8, 
      args=0xbfffdd4c) at /src/swarm-2.1.1/libobjc/sendmsg.c:571
  #4  0x40232f8d in __objc_word_forward (rcv=0x81029b0, op=0x804d0c8)
      at /src/swarm-2.1.1/libobjc/sendmsg.c:499
  #5  0x4002b97b in L10 () from /packages/math/swarm/lib/libswarm.so.0
  #6  0x401be2b3 in objc_call (fa=0x8324fc0)
      at /src/swarm-2.1.1/src/defobj/_fcall.m:167
  #7  0x401b02af in _i_FCall_c__performCall (self=0x83258b0, _cmd=0x40179860)
      at /src/swarm-2.1.1/src/defobj/FCall.m:550
  #8  0x40166104 in _i_ActionTo_c___performAction__ (self=0x8324f80, 
      _cmd=0x4017e528, anActivity=0x8104790)
      at /src/swarm-2.1.1/src/activity/Action.m:286
  #9  0x4016f9bb in _i_Activity_c___run_ (self=0x8104790, _cmd=0x4017e510)
      at /src/swarm-2.1.1/src/activity/XActivity.m:190
  #10 0x4016f8bd in _i_Activity_c___run_ (self=0x8327880, _cmd=0x4017e510)
      at /src/swarm-2.1.1/src/activity/XActivity.m:148
  #11 0x4016f8bd in _i_Activity_c___run_ (self=0x8327b30, _cmd=0x4017e510)
      at /src/swarm-2.1.1/src/activity/XActivity.m:148
  #12 0x4016f8bd in _i_Activity_c___run_ (self=0x8326620, _cmd=0x4017e4f8)
      at /src/swarm-2.1.1/src/activity/XActivity.m:148
  #13 0x4016f779 in _i_Activity_c__run (self=0x8326620, _cmd=0x4005c2b8)
      at /src/swarm-2.1.1/src/activity/XActivity.m:76
  #14 0x4004e382 in _i_ControlPanel__startInActivity_ (self=0x81029b0, 
      _cmd=0x4005cad8, activityID=0x8326620)
      at /src/swarm-2.1.1/src/simtoolsgui/ControlPanel.m:100
  #15 0x4004eebf in _i_GUISwarm__go (self=0x80b5de0, _cmd=0x804cce0)
      at /src/swarm-2.1.1/src/simtoolsgui/GUISwarm.m:49
  #16 0x804900a in main (argc=1, argv=0xbfffe51c) at main.m:39
  #17 0x405b216b in __libc_start_main () from /lib/libc.so.6
  (gdb) quit


Here is my patch relative to:

  ftp.swarm.org:/pub/swarm/src/users-contrib/anarchy/potential.tar.gz


---cut-here------cut-here------cut-here------cut-here------cut-here---
diff -r -u potential/Charge.h potential-new/Charge.h
--- potential/Charge.h  Sat Jul 26 10:17:40 1997
+++ potential-new/Charge.h      Wed Apr 25 23:32:59 2001
@@ -2,7 +2,7 @@
 
 //Charge.h     potential    by Artan Simeqi
 
-#import <swarmobject/SwarmObject.h>
+#import <objectbase/SwarmObject.h>
 #import <space.h>
 #import <simtools.h>
 
@@ -12,7 +12,7 @@
 int xPos, yPos;
 int worldXSize, worldYSize;
 
-Grid2d * world;
+id <Grid2d> world;
 double  charge;
 int sign;   //used also as a color when drawing the charge.
 
@@ -23,7 +23,7 @@
 -createEnd;
 
 -setX: (int) x Y: (int) y;
--drawSelfOn: (Raster *) r;
+-drawSelfOn: (id <Raster>) r;
 -setCharge: (double) c Sign: (int) s;
 - (double) getCharge;
 @end
diff -r -u potential/Charge.m potential-new/Charge.m
--- potential/Charge.m  Sat Jul 26 10:17:40 1997
+++ potential-new/Charge.m      Wed Apr 25 23:32:47 2001
@@ -36,7 +36,7 @@
 return charge;
 }
 
--drawSelfOn: (Raster *) r {
+-drawSelfOn: (id <Raster>) r {
 [r drawPointX: xPos Y: yPos Color: (sign+1)]; //Red color is negative charge
                                              //Yellow color is positive
                                              //White color is neutral
diff -r -u potential/Makefile potential-new/Makefile
--- potential/Makefile  Sat Jul 26 10:17:40 1997
+++ potential-new/Makefile      Wed Apr 25 23:04:22 2001
@@ -1,8 +1,15 @@
-SWARMHOME=/usr/src/swarm/swarm-1.0.2
+ifeq ($(SWARMHOME),)
+SWARMHOME=../swarm-2.1.1
+endif
 APPLICATION=potential
-OBJECTS=Charge.o  Ppoint.o main.o ObserverSwarm.o ModelSwarm.o 
address@hidden
+APPVERSION=2.1.1
+APPLIBS=-lspace
+OBJECTS=Charge.o Ppoint.o main.o ObserverSwarm.o ModelSwarm.o
+
+include $(SWARMHOME)/etc/swarm/Makefile.appl
+
 APPLIBS=-lspace
-include $(SWARMHOME)/Makefile.appl
 
 main.o: main.m ObserverSwarm.h Charge.h Ppoint.h 
 Charge.o: Charge.h Charge.m
diff -r -u potential/ModelSwarm.h potential-new/ModelSwarm.h
--- potential/ModelSwarm.h      Sat Jul 26 10:17:40 1997
+++ potential-new/ModelSwarm.h  Wed Apr 25 23:39:07 2001
@@ -3,12 +3,12 @@
 #import "Charge.h"
 #import "Ppoint.h"
 
-#import <swarmobject/Swarm.h>
+#import <objectbase/Swarm.h>
 #import <space.h>
 #import <activity.h>
 #import <collections.h>
-#import <tkobjc.h>
-#import <swarmobject.h>
+#import <gui.h>
+#import <objectbase/SwarmObject.h>
 #import <simtools.h>
 
 @interface ModelSwarm: Swarm {
@@ -19,7 +19,7 @@
   int count1;       //size of  the realChargesArray
   double minPotential;
   double maxPotential;
-  Grid2d * world;
+  id <Grid2d> world;
   
   id arrayOfPoints;
   id  arrayOfCharges;
diff -r -u potential/ModelSwarm.m potential-new/ModelSwarm.m
--- potential/ModelSwarm.m      Sat Jul 26 10:17:40 1997
+++ potential-new/ModelSwarm.m  Wed Apr 25 23:39:56 2001
@@ -24,7 +24,7 @@
 
 +createBegin: (id) aZone {
   ModelSwarm * obj;
-  ProbeMap * probeMap;
+  id <ProbeMap> probeMap;
 
   // in createBegin, we set up the simulation parameters
 
diff -r -u potential/ObserverSwarm.h potential-new/ObserverSwarm.h
--- potential/ObserverSwarm.h   Sat Jul 26 10:17:40 1997
+++ potential-new/ObserverSwarm.h       Wed Apr 25 23:30:14 2001
@@ -2,12 +2,13 @@
 
 #import "ModelSwarm.h"
 
-#import <swarmobject.h>
+#import <objectbase/SwarmObject.h>
 #import <space.h>
 #import <activity.h>
-#import <tkobjc.h>
+#import <gui.h>
 #import <collections.h>
 #import <simtools.h>
+#import <simtoolsgui/GUISwarm.h>
 #import <analysis.h>
 
 @interface ObserverSwarm : GUISwarm {
@@ -20,13 +21,13 @@
 
   // Lots of display objects. First, widgets
 
-  XColormap * colorMap;                           // allocate colours
-  ZoomRaster * worldRaster;                       // 2d display widget
+  id <Colormap> colorMap;                           // allocate colours
+  id <ZoomRaster> worldRaster;                       // 2d display widget
 
  // Now, higher order display and data objects
 
-  Object2dDisplay * pointDisplay;                   // display the points
-  Object2dDisplay * chargeDisplay;                   // display the charges
+  id <Object2dDisplay> pointDisplay;                   // display the points
+  id <Object2dDisplay> chargeDisplay;                   // display the charges
 }
 
 // Methods overriden to make the Swarm.
diff -r -u potential/ObserverSwarm.m potential-new/ObserverSwarm.m
--- potential/ObserverSwarm.m   Sat Jul 26 10:17:40 1997
+++ potential-new/ObserverSwarm.m       Wed Apr 25 23:31:13 2001
@@ -6,7 +6,7 @@
 
 +createBegin: (id) aZone {
   ObserverSwarm * obj;
-  ProbeMap * probeMap;
+  id <ProbeMap> probeMap;
 
   // createBegin: here we set up the default simulation parameters.
 
@@ -80,7 +80,7 @@
   // First, create a colormap: this is a global resource, the information
   // here is used by lots of different objects.
 
-  colorMap = [XColormap create: [self getZone]];
+  colorMap = [Colormap create: [self getZone]];
 
   [colorMap setColor: 0 ToName: "red"];  //negative charges
   [colorMap setColor: 1 ToName: "white"];  //neutral charges
diff -r -u potential/Ppoint.h potential-new/Ppoint.h
--- potential/Ppoint.h  Sat Jul 26 10:17:40 1997
+++ potential-new/Ppoint.h      Wed Apr 25 23:33:31 2001
@@ -1,6 +1,6 @@
 //Ppoint.h         potential      by Artan Simeqi
 
-#import <swarmobject/SwarmObject.h>
+#import <objectbase/SwarmObject.h>
 #import <space.h>
 #import <collections.h>
 #import <simtools.h>
@@ -12,7 +12,7 @@
 int worldXSize, worldYSize;
 int count;   //size of the array of the charges
 id  arrayOfCharges;
-Grid2d * world;
+id <Grid2d> world;
 double  potential;
 int color;
 double rcol;
@@ -23,7 +23,7 @@
 -createEnd;
 
 -setX: (int) x Y: (int) y;
--drawSelfOn: (Raster *) r;
+-drawSelfOn: (id <Raster>) r;
 -setPotential;
 - (double) getPotential;
 -setColorMinPot:  (double) minPot 
diff -r -u potential/Ppoint.m potential-new/Ppoint.m
--- potential/Ppoint.m  Sat Jul 26 10:17:40 1997
+++ potential-new/Ppoint.m      Wed Apr 25 23:33:55 2001
@@ -54,7 +54,7 @@
 - (double) getPotential {
 return potential;
 }
--drawSelfOn: (Raster *) r {
+-drawSelfOn: (id <Raster>) r {
 [r drawPointX: xPos Y: yPos Color: color];
 return self;
 }
diff -r -u potential/main.m potential-new/main.m
--- potential/main.m    Sat Jul 26 10:17:40 1997
+++ potential-new/main.m        Wed Apr 25 23:38:26 2001
@@ -4,13 +4,14 @@
 #import "ObserverSwarm.h"
 
 #import <simtools.h>                // ... for initSwarm() 
+#import <simtoolsgui.h>
 
 // The main() function is the top-level place where everything starts.
 // For a typical Swarm simulation, in main() you create a toplevel
 // Swarm, let it build and activate, and set it to running.
 
 int
-main(int argc, char ** argv) {
+main(int argc, const char ** argv) {
   ObserverSwarm * observerSwarm;
 
   // Swarm initialization: all Swarm apps must call this first.


-- 
Russell Senior         ``The two chiefs turned to each other.        
address@hidden      Bellison uncorked a flood of horrible       
                         profanity, which, translated meant, `This is
                         extremely unusual.' ''                      

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]