You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by "brian wickman (JIRA)" <ji...@apache.org> on 2012/12/04 02:29:58 UTC

[jira] [Comment Edited] (MESOS-317) python mesos core bindings rejects framework messages with null bytes

    [ https://issues.apache.org/jira/browse/MESOS-317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13509414#comment-13509414 ] 

brian wickman edited comment on MESOS-317 at 12/4/12 1:28 AM:
--------------------------------------------------------------

it looks like you should be parsing the string using "s#" and not "s"

currently, you have:

  const char* data;
  if (!PyArg_ParseTuple(args, "s", &data)) {
    return NULL;
  }

  Status status = self->driver->sendFrameworkMessage(data);
  return PyInt_FromLong(status); // Sets an exception if creating the int fails



you want:

  const char* data;
  int data_size;
  if (!PyArg_ParseTuple(args, "s#", &data, &data_size)) {
    return NULL;
  }
  std::string cpp_data = string(data, data_size);

  Status status = self->driver->sendFrameworkMessage(cpp_data);
  return PyInt_FromLong(status); // Sets an exception if creating the int fails

                
      was (Author: wickman):
    it looks like you should be parsing the string using "s#" and not "s"

currently, you have:

  const char* data;
  int data_size;
  if (!PyArg_ParseTuple(args, "s", &data)) {
    return NULL;
  }

  Status status = self->driver->sendFrameworkMessage(data);
  return PyInt_FromLong(status); // Sets an exception if creating the int fails



you want:

  const char* data;   
  if (!PyArg_ParseTuple(args, "s#", &data, &data_size)) {
    return NULL;
  }
  std::string cpp_data = string(data, data_size);

  Status status = self->driver->sendFrameworkMessage(cpp_data);
  return PyInt_FromLong(status); // Sets an exception if creating the int fails

                  
> python mesos core bindings rejects framework messages with null bytes
> ---------------------------------------------------------------------
>
>                 Key: MESOS-317
>                 URL: https://issues.apache.org/jira/browse/MESOS-317
>             Project: Mesos
>          Issue Type: Bug
>          Components: python-api
>            Reporter: brian wickman
>
> We're getting exceptions when sending frameworkMessages, specifically
> smf1-aaj-35-sr1.prod.twitter.com:  Exception in thread Thread-2:
> smf1-aaj-35-sr1.prod.twitter.com:  Traceback (most recent call last):
> smf1-aaj-35-sr1.prod.twitter.com:    File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
> smf1-aaj-35-sr1.prod.twitter.com:      self.run()
> smf1-aaj-35-sr1.prod.twitter.com:    File "twitter/common/concurrent/deferred.py", line 43, in run
> smf1-aaj-35-sr1.prod.twitter.com:      self._closure()
> smf1-aaj-35-sr1.prod.twitter.com:    File "/var/lib/mesos/slaves/201211292101-1968906762-5050-60720-1356/frameworks/201104070004-0000002563-0000/executors/gc-66e0daf8-b527-4d7c-ab17-ff6671acc0ff/runs/0/gc_executor.pex/gc_executor.py", line 207, in <lambda>
> smf1-aaj-35-sr1.prod.twitter.com:    File "/var/lib/mesos/slaves/201211292101-1968906762-5050-60720-1356/frameworks/201104070004-0000002563-0000/executors/gc-66e0daf8-b527-4d7c-ab17-ff6671acc0ff/runs/0/gc_executor.pex/gc_executor.py", line 195, in run_gc
> smf1-aaj-35-sr1.prod.twitter.com:  TypeError: argument 1 must be string without null bytes, not str
> smf1-aaj-35-sr1.prod.twitter.com:  
> The Java executor handles strings with \0 bytes just fine.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira