From: aneves <a20...@al...> - 2010-08-31 12:28:23
|
I'm still having problems with the memory allocation. I did it this way: this->map_data.data = (int8_t *)malloc(this->map_data.data_count*sizeof(int8_t)); And had this error: slamdriver.cc:153: error: incompatible types in assignment of ‘int8_t*’ to ‘int8_t [8380162]’ About the queue overflow, it just hapen when i try to use the map. So I think is something wrong wth my driver code.. Rich Mattes-2 wrote: > > When you create a new player_map_data_t variable, the "data" pointer will > always point to an invalid memory space until you allocate memory for it > (or set it equal to another pointer that's already allocated.) If you > have your player_map_data_t at the class level, you can get away with > allocating data once, but if you need to change the size of the data array > you'll have to free and reallocate it. Gridmap creates a new > player_map_data_t for each map request, and handles allocating, using, and > freeing the memory properly. > > The queue overflow is happening because you're not calling Read() fast > enough. Messages are being published from the Player server and landing > in your PlayerClient's message queue. Read() will take information out of > the message queue and copy it into the appropriate proxies. You can call > Read() or ReadIfWaiting() more often to solve this. You can also use > SetReplaceRule on one or more of your client proxies; setting the replace > rule to true will cause new messages to overwrite older messages in the > message queue, instead of queuing them up. > > All of the libplayerc++ features and functions are outlined in the > documentation online at > http://playerstage.sourceforge.net/doc/Player-svn/player/group__player__clientlib__cplusplus.html > I find it useful to refer to when I'm wondering about how a particular > proxy works. > > > Rich > > -----Original Message----- > From: aneves [mailto:a20...@al...] > Sent: Monday, August 30, 2010 1:09 PM > To: pla...@li... > Subject: Re: [Playerstage-developers] Help with map driver > > > Hi Rich! > > Thanks a lot. You solved my problem. The problem was the lack of > RequestMap(). I never used the MapProxy before :blush:. > > For now i'm not having problems with the allocation but i'll do what you > say. If I understood right it's only a matter of time untill the pointer > points randomly to a forbiden section of the memory. > > Now i'm having some queue overflow after the program is running for a > while. > "playerc error : queue overflow; discarding packets" > > Any ideas why? > > Thnaks once again. you are saving my life:) > > > > > Rich Mattes-2 wrote: >> >> 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 >> >> >> ------------------------------------------------------------------------------ >> 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 >> >> > > -- > View this message in context: > http://old.nabble.com/Help-with-map-driver-tp29571142p29574915.html > Sent from the playerstage-developers mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Playerstage-developers mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-developers > > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Playerstage-developers mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-developers > > -- View this message in context: http://old.nabble.com/Help-with-map-driver-tp29571142p29582404.html Sent from the playerstage-developers mailing list archive at Nabble.com. |