summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2014-10-31 16:01:19 -0700
committerTim O'Shea <tim.oshea753@gmail.com>2014-12-26 19:05:01 +0100
commitc1f42c12af1b4deedf7d72c477b40d4cc369ee41 (patch)
treef7c522f2c5afb4f68c5f6cb129cb775644a6fdf9
parent57c8dd13b4ede4bf255327611afcd877d6f881f3 (diff)
zeromq: fix segfault in tag_headers
-rw-r--r--gr-zeromq/lib/tag_headers.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/gr-zeromq/lib/tag_headers.cc b/gr-zeromq/lib/tag_headers.cc
index b45025d904..42a65be5af 100644
--- a/gr-zeromq/lib/tag_headers.cc
+++ b/gr-zeromq/lib/tag_headers.cc
@@ -33,10 +33,12 @@ namespace gr {
std::stringstream ss;
size_t ntags = tags.size();
- ss.write( reinterpret_cast< const char* >( offset ), sizeof(uint64_t) ); // offset
+ ss.write( reinterpret_cast< const char* >( &offset ), sizeof(uint64_t) ); // offset
ss.write( reinterpret_cast< const char* >( &ntags ), sizeof(size_t) ); // num tags
std::stringbuf sb("");
+ std::cout << "TX TAGS: (offset="<<offset<<" ntags="<<ntags<<")\n";
for(size_t i=0; i<tags.size(); i++){
+ std::cout << "TX TAG: (" << tags[i].offset << ", " << tags[i].key << ", " << tags[i].value << ", " << tags[i].srcid << ")\n";
ss.write( reinterpret_cast< const char* >( &tags[i].offset ), sizeof(uint64_t) ); // offset
sb.str("");
pmt::serialize( tags[i].key, sb ); // key
@@ -51,17 +53,28 @@ namespace gr {
std::string
parse_tag_header(std::string &buf_in, uint64_t &offset_out, std::vector<gr::tag_t> tags_out) {
+ std::cout << "sblen: " << buf_in.size() <<"\n";
std::istringstream iss( buf_in );
size_t rcv_ntags;
iss.read( (char*)&offset_out, sizeof(uint64_t ) );
iss.read( (char*)&rcv_ntags, sizeof(size_t ) );
+ std::cout << "RX TAGS: (offset="<<offset_out<<" ntags="<<rcv_ntags<<")\n";
+ int rd_offset = sizeof(uint64_t) + sizeof(size_t);
for(size_t i=0; i<rcv_ntags; i++){
gr::tag_t newtag;
iss.read( (char*)&newtag.offset, sizeof(uint64_t ) );
- std::stringbuf sb( iss.str() );
+ rd_offset += sizeof(uint64_t);
+
+ std::stringbuf sb( iss.str().substr(rd_offset) );
+ std::cout << "sblen: " << sb.str().size() << "\n";
+ std::cout << "sbloc: " << sb.getloc() << "\n";
+ //std::stringbuf sb( iss.str() );
+
newtag.key = pmt::deserialize( sb );
newtag.value = pmt::deserialize( sb );
newtag.srcid = pmt::deserialize( sb );
+ std::cout << "sblen(after): " << sb.str().size() << "\n";
+ std::cout << "sbloc(after): " << sb.getloc() << "\n";
tags_out.push_back(newtag);
iss.str(sb.str());
}