You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by mmartell <gi...@git.apache.org> on 2017/02/16 15:59:38 UTC

[GitHub] geode-native pull request #15: GEODE-2484: Fix snprintf error. Need #include...

GitHub user mmartell opened a pull request:

    https://github.com/apache/geode-native/pull/15

    GEODE-2484: Fix snprintf error. Need #include <cstdio>.

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mmartell/geode-native feature/GEODE-2484

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/geode-native/pull/15.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #15
    
----
commit 5a215532d13d903b8c0a229c0d6fccbe8c0ef809
Author: Mike Martell <mm...@pivotal.io>
Date:   2017-02-16T15:57:11Z

    GEODE-2484: Fix snprintf error. Need #include <cstdio>.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #15: GEODE-2484: Fix snprintf error. Need #include...

Posted by mmartell <gi...@git.apache.org>.
Github user mmartell closed the pull request at:

    https://github.com/apache/geode-native/pull/15


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #15: GEODE-2484: Fix snprintf error. Need #include...

Posted by dgkimura <gi...@git.apache.org>.
Github user dgkimura commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/15#discussion_r101655637
  
    --- Diff: src/cppcache/src/TcrMessage.hpp ---
    @@ -1113,12 +1117,11 @@ class TcrMessageHelper {
           return NULL_OBJECT;
         } else if (!isObj) {
           // otherwise we're currently always expecting an object
    -      char exMsg[256];
    -      std::snprintf(exMsg, 255,
    -                    "TcrMessageHelper::readChunkPartHeader: "
    -                    "%s: part is not object",
    -                    methodName);
    -      LOGDEBUG("%s ", exMsg);
    +
    +      std::stringstream s;
    +      s << "TcrMessageHelper::readChunkPartHeader: " << methodName << ": part is not object\n";
    +      LOGDEBUG("%s ", s.str().c_str());
    --- End diff --
    
    I find this line a little suspicious.  If I understand correctly, `stringstream.str()` will return a temporary string object and then `c_str()` will return a pointer to that temporary object.  Then it seems like it may be possible that temporary string is freed after the expression is evaluated.  And then we would be referencing a freed object inside `LOGDEBUG` which would lead to undefined behavior.  If I am misunderstanding then please educate me how this works and why you chose to do it!  :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #15: GEODE-2484: Fix snprintf error. Need #include...

Posted by dgkimura <gi...@git.apache.org>.
Github user dgkimura commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/15#discussion_r101580799
  
    --- Diff: src/cppcache/src/TcrMessage.hpp ---
    @@ -1135,7 +1137,7 @@ class TcrMessageHelper {
             return EXCEPTION;
           } else {
             char exMsg[256];
    -        std::snprintf(
    +        snprintf(
    --- End diff --
    
    Why are you removing the namespace specifier here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native issue #15: GEODE-2484: Fix snprintf error. Need #include Posted by mmartell <gi...@git.apache.org>.
Github user mmartell commented on the issue:

    https://github.com/apache/geode-native/pull/15
  
    Whoops. Forgot to format. Fixing now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native issue #15: GEODE-2484: Fix snprintf error. Need #include Posted by mmartell <gi...@git.apache.org>.
Github user mmartell commented on the issue:

    https://github.com/apache/geode-native/pull/15
  
    On Thu, Feb 16, 2017 at 12:09 PM Michael Martell <mm...@pivotal.io>
    wrote:
    
    > Something is screwed up in our #includes. TcrMessage.cpp compiles fine
    > leaving the std:: in there. However, other classes that include it don't
    > compile (like DistributedSystem).
    >
    > I'd rather spend time switching to newer constructs (<stream> and
    > <iostream>). Simple change, and for now we can convert the streamstrimg
    > back to char* when passing to logger.
    >
    > On Thu, Feb 16, 2017 at 11:50 AM Jacob Barrett <no...@github.com>
    > wrote:
    >
    > *@pivotal-jbarrett* requested changes on this pull request.
    > ------------------------------
    >
    > In src/cppcache/src/TcrMessage.hpp
    > <https://github.com/apache/geode-native/pull/15#discussion_r101610701>:
    >
    > > @@ -1114,10 +1116,10 @@ class TcrMessageHelper {
    >      } else if (!isObj) {
    >        // otherwise we're currently always expecting an object
    >        char exMsg[256];
    > -      std::snprintf(exMsg, 255,
    > -                    "TcrMessageHelper::readChunkPartHeader: "
    > -                    "%s: part is not object",
    > -                    methodName);
    > +      snprintf(exMsg, 255,
    >
    > If you had to remove std:: to make this work then it isn't working like
    > you think it is. Let's figure out why and fix correctly,
    >
    > \u2014
    > You are receiving this because you authored the thread.
    > Reply to this email directly, view it on GitHub
    > <https://github.com/apache/geode-native/pull/15#pullrequestreview-22345908>,
    > or mute the thread
    > <https://github.com/notifications/unsubscribe-auth/AP6jX5v5lFuHm4O8jYJ90Gf12XL1Bq1eks5rdKiSgaJpZM4MDMYN>
    > .
    >
    >



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native issue #15: GEODE-2484: Fix snprintf error. Need #include Posted by metatype <gi...@git.apache.org>.
Github user metatype commented on the issue:

    https://github.com/apache/geode-native/pull/15
  
    Did you tag the wrong JIRA issue?  I don't see anything related to GEODE-2484.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native issue #15: GEODE-2484: Fix snprintf error. Need #include Posted by mmartell <gi...@git.apache.org>.
Github user mmartell commented on the issue:

    https://github.com/apache/geode-native/pull/15
  
    Something is screwed up in our #includes. TcrMessage.cpp compiles fine
    leaving the std:: in there. However, other classes that include it don't
    compile (like Distributed System).
    
    I'd rather spend time switching to newer constructs (<stream> and
    <upstream>). Simple change, and for now we can convert the streamstrimg
    back to char* when passing to logger.
    
    On Thu, Feb 16, 2017 at 11:50 AM Jacob Barrett <no...@github.com>
    wrote:
    
    > *@pivotal-jbarrett* requested changes on this pull request.
    > ------------------------------
    >
    > In src/cppcache/src/TcrMessage.hpp
    > <https://github.com/apache/geode-native/pull/15#discussion_r101610701>:
    >
    > > @@ -1114,10 +1116,10 @@ class TcrMessageHelper {
    >      } else if (!isObj) {
    >        // otherwise we're currently always expecting an object
    >        char exMsg[256];
    > -      std::snprintf(exMsg, 255,
    > -                    "TcrMessageHelper::readChunkPartHeader: "
    > -                    "%s: part is not object",
    > -                    methodName);
    > +      snprintf(exMsg, 255,
    >
    > If you had to remove std:: to make this work then it isn't working like
    > you think it is. Let's figure out why and fix correctly,
    >
    > \u2014
    > You are receiving this because you authored the thread.
    > Reply to this email directly, view it on GitHub
    > <https://github.com/apache/geode-native/pull/15#pullrequestreview-22345908>,
    > or mute the thread
    > <https://github.com/notifications/unsubscribe-auth/AP6jX5v5lFuHm4O8jYJ90Gf12XL1Bq1eks5rdKiSgaJpZM4MDMYN>
    > .
    >



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native issue #15: GEODE-2484: Fix snprintf error. Need #include Posted by mmartell <gi...@git.apache.org>.
Github user mmartell commented on the issue:

    https://github.com/apache/geode-native/pull/15
  
    David,
    
    I had to remove the std:: to get it to build on Windows. I tested my fix on
    Windows and Mac only.
    
    On Thu, Feb 16, 2017 at 9:41 AM, Anthony Baker <no...@github.com>
    wrote:
    
    > Did you tag the wrong JIRA issue? I don't see anything related to
    > GEODE-2484.
    >
    > \u2014
    > You are receiving this because you authored the thread.
    > Reply to this email directly, view it on GitHub
    > <https://github.com/apache/geode-native/pull/15#issuecomment-280403226>,
    > or mute the thread
    > <https://github.com/notifications/unsubscribe-auth/AP6jX-PjdDFzz0M1wpmA35nft2kGmjr7ks5rdIo-gaJpZM4MDMYN>
    > .
    >



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #15: GEODE-2484: Fix snprintf error. Need #include...

Posted by pivotal-jbarrett <gi...@git.apache.org>.
Github user pivotal-jbarrett commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/15#discussion_r101610701
  
    --- Diff: src/cppcache/src/TcrMessage.hpp ---
    @@ -1114,10 +1116,10 @@ class TcrMessageHelper {
         } else if (!isObj) {
           // otherwise we're currently always expecting an object
           char exMsg[256];
    -      std::snprintf(exMsg, 255,
    -                    "TcrMessageHelper::readChunkPartHeader: "
    -                    "%s: part is not object",
    -                    methodName);
    +      snprintf(exMsg, 255,
    --- End diff --
    
    If you had to remove std:: to make this work then it isn't working like you think it is. Let's figure out why and fix correctly,


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #15: GEODE-2484: Fix snprintf error. Need #include...

Posted by pivotal-jbarrett <gi...@git.apache.org>.
Github user pivotal-jbarrett commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/15#discussion_r101662122
  
    --- Diff: src/cppcache/src/TcrMessage.hpp ---
    @@ -1113,12 +1117,11 @@ class TcrMessageHelper {
           return NULL_OBJECT;
         } else if (!isObj) {
           // otherwise we're currently always expecting an object
    -      char exMsg[256];
    -      std::snprintf(exMsg, 255,
    -                    "TcrMessageHelper::readChunkPartHeader: "
    -                    "%s: part is not object",
    -                    methodName);
    -      LOGDEBUG("%s ", exMsg);
    +
    +      std::stringstream s;
    +      s << "TcrMessageHelper::readChunkPartHeader: " << methodName << ": part is not object\n";
    +      LOGDEBUG("%s ", s.str().c_str());
    --- End diff --
    
    Good question. I am still fascinated as to why std::snprintf isn't working correctly on Windows too.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] geode-native pull request #15: GEODE-2484: Fix snprintf error. Need #include...

Posted by dgkimura <gi...@git.apache.org>.
Github user dgkimura commented on a diff in the pull request:

    https://github.com/apache/geode-native/pull/15#discussion_r101652960
  
    --- Diff: src/cppcache/src/TcrMessage.hpp ---
    @@ -20,6 +20,10 @@
      * limitations under the License.
      */
     
    +//#include <cstdio>
    --- End diff --
    
    No need for this line in current revision.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---