From: Rich M. <jp...@gm...> - 2010-08-30 15:43:33
|
I just checked the gridmap driver in svn, it is using "new" to allocate the data array: mapresp->data = new int8_t [mapresp->data_count]; In the map data structure, the "data" field is declared pointer to a double, as opposed to the other values which are declared directly. When you initialize a player_map_data_t, all of the other fields have a value, but the pointer "data" is pointing at a random section of memory. If you don't allocate it using either "new" or "malloc", any attempt to write to the variable is going to cause a segmentation violation (which is a memory access error). Make sure you create the data variable before writing to it, and then de-allocate it (with delete or free) after you publish it. As far as your client program, it looks like it's breaking at the GetCell() command. You need to use RequestMap() to fill in the map data before you try to access any of the map data. If the underlying driver doesn't respond properly to RequestMap, that might also cause a failure. Rich -----Original Message----- From: aneves [mailto:a20...@al...] Sent: Monday, August 30, 2010 9:56 AM To: pla...@li... Subject: Re: [Playerstage-developers] Help with map driver Rich Mattes-2 wrote: > > Have you tried using gdb on your driver? make sure that your plugin is > compiled with the -g option, then run > now is my client program that's faulting here's the gdb output from him: neves@neves:~/code/driver/test_client$ gdb ./loa GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Lendo símbolos de /home/neves/code/driver/test_client/loa...concluído. (gdb) run Starting program: /home/neves/code/driver/test_client/loa [Thread debugging using libthread_db enabled] calling connect done minR: 1e+09 minL: 1e+09 Program received signal SIGSEGV, Segmentation fault. 0x080498d3 in PlayerCc::ClientProxy::GetVar<char> (argc=1, argv=0xbffff3a4) at /usr/include/player-2.0/libplayerc++/clientproxy.h:116 116 T v = aV; (gdb) bt #0 0x080498d3 in PlayerCc::ClientProxy::GetVar<char> (argc=1, argv=0xbffff3a4) at /usr/include/player-2.0/libplayerc++/clientproxy.h:116 #1 PlayerCc::MapProxy::GetCell (argc=1, argv=0xbffff3a4) at /usr/include/player-2.0/libplayerc++/playerc++.h:1219 #2 main (argc=1, argv=0xbffff3a4) at laserobstacleavoid.cc:80 (gdb) list 111 // c library to make sure the data access is thread safe. 112 template<typename T> 113 T GetVar(const T &aV) const 114 { // these have to be defined here since they're templates 115 scoped_lock_t lock(mPc->mMutex); 116 T v = aV; 117 return v; 118 } 119 120 // @brief Get a variable from the client by reference > Once the program segfaults, use the 'bt' and 'list' commands to determine > where your program was when it crashed. The below code snippet isn't > enough > to tell the whole story, but are you allocating map_data.data before you > attempt to write to it? You should allocate it with the "new" keyword or > with "malloc". > > Rich > I'm not using "malloc" nor "new". I just copied this part from the gridmap driver and it too doesn't use "malloc" or "new". I'm really lost! thanks for your help , andré -- View this message in context: http://old.nabble.com/Help-with-map-driver-tp29571142p29572784.html Sent from the playerstage-developers mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ Playerstage-developers mailing list Pla...@li... https://lists.sourceforge.net/lists/listinfo/playerstage-developers |