Find the answer to your Linux question:
Results 1 to 4 of 4
void AppBuf(message_id_type msgID, int32 numPairs, va_list va) { int32 len = va_args(va, int32); .... } The above piece of code runs perfectly fine on windows (32 and 64 bit) and ...
  1. #1
    Just Joined!
    Join Date
    Jul 2011
    Posts
    2

    (c++) va_args(va, int32) gives very large value on x86_64 GNU/Linux

    void AppBuf(message_id_type msgID, int32 numPairs, va_list va)

    {
    int32 len = va_args(va, int32);
    ....
    }

    The above piece of code runs perfectly fine on windows (32 and 64 bit) and also on linux 32 bit compiler. Value of 'len' comes out to 10 for all the above.

    But on linux 64 bit (x86_64 GNU/Linux) I am getting a very large value for len (50462976), which messes up the rest of the code and end ups in a crash.

    I had read that something has changed in linux 64 bit compilers with respect to va_lists but I was not able to understand the change and so I was not able to fix my issue.

    Could someone please help me with this issue?

    Thanks.

    The details of the whole code leading upto this point: Could someone please help with this? Thanks in advance.

    Call Stack:

    AppendBuffers(int msgID=0x00000001, int numPairs=0x00000001, char * va=0x0007fcb0) {NOTE: this is where the problem is occuring as mentioned above (length = very large)}

    LogMsg(int msgID=0x00000001, int numPairs=0x00000001, char * arguments=0x0007fcb0)

    LogMsgBuffersV(int msgID=0x00000001, int numPairs=0x00000001, char * arguments=0x0007fcb0)

    LogMsgBuffersV(int msgID=0x00000001, int numPairs=0x00000001, char * arguments=0x0007fcb0)

    LogMsgBuffers(int msgID=0x00000001, int numPairs=0x00000001, ...)

    Actual code:

    void LogMsgBuffers(message_id_type msgID, int32 numPairs, ...)
    {

    va_list arguments;
    va_start(arguments, numPairs);

    filter_status_type msgStatus = FilterMsg(msgID);

    if (msgStatus == FILTER_ACCEPT)
    {
    LogMsg(msgID, numPairs, arguments);
    }

    if ((_parentLogger != NULL) && (_oAppenderInheritance))
    {
    //Pass the msg to the parent
    _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments);
    }

    return;
    }

    void LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments)
    {

    filter_status_type msgStatus = FilterMsg(msgID);

    if (msgStatus == FILTER_ACCEPT)
    {
    //Log msg to the current node
    LogMsg(msgID, numPairs, arguments);
    }

    if ((_parentLogger != NULL) && (_oAppenderInheritance))
    {
    //Pass the msg to the parent
    _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments);

    }
    return;
    }

    void LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments)
    {
    filter_status_type msgStatus = FilterMsg(msgID);

    if (msgStatus == FILTER_ACCEPT)
    {
    //Log msg to the current node
    LogMsg(msgID, numPairs, arguments);
    }

    if ((_parentLogger != NULL) && (_oAppenderInheritance))
    {
    //Pass the msg to the parent
    _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments);

    }
    return;
    }

    void LogMsg(message_id_type msgID, int32 numPairs, va_list arguments)
    {
    uint32 i;

    for (i = 0; i < _pOwnAppenderVec.size(); i++)
    {
    LoggerAppender *appender = _pOwnAppenderVec[i];
    appender->AppendBuffers(msgID, numPairs, arguments);
    }
    return;
    }

    void AppendBuffers(message_id_type msgID, int32 numPairs, va_list va)
    {

    for (int32 i = 0; i < numPairs; i++)
    {
    int32 length = va_arg(va, int32);
    uint8* buffer = va_arg(va, uint8*);

    int32 jj;
    for (jj = 10; jj < length; jj += 10)
    {
    AppendStringA(0, " %x %x %x %x %x %x %x %x %x %x", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8], buffer[9]);
    buffer += 10;
    }

    uint8 remainderbuf[10];
    uint32 remainder = length - (jj - 10);
    if (remainder > 0 && remainder <= 10)
    {
    oscl_memcpy(remainderbuf, buffer, remainder);
    oscl_memset(remainderbuf + remainder, 0, 10 - remainder);
    buffer = remainderbuf;
    AppendStringA(0, " %x %x %x %x %x %x %x %x %x %x", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8], buffer[9]);
    }
    }
    va_end(va);
    }

  2. #2
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Please use code tags to make your code readable.

    Your va_list is built from the variable arguments passed in LogMsgBuffers(), but I do not see the call to that function - that's probably where things are going wrong.

  3. #3
    Just Joined!
    Join Date
    Jul 2011
    Posts
    2
    Call to LogMsgBuffers() is from the following code:

    Code:
    void module1()
            {
                uint8 buf[10] = {0x00, 0x01, 0x02, 0x03, 0x04,
                                 0x05, 0x06, 0x07, 0x08, 0x09
                                };
    
                // text messages
                Logger *logger = Logger::GetLoggerObject("mod1");
                test_is_true(logger != NULL);
                LOGGER_LOGMSG(LOGMSG_INST_LLDBG, logger, 1, (1, "Test Logging of module 1"));
    
           // binary data, this is from where LogMsgBuffers() is called
                LOGGER_LOGBIN(LOGMSG_INST_LLDBG, bin1logger, 1, (1, 1, 10, buf));
            }

  4. #4
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Quote Originally Posted by jsingh125 View Post
    Call to LogMsgBuffers() is from the following code:

    Code:
           // binary data, this is from where LogMsgBuffers() is called
                LOGGER_LOGBIN(LOGMSG_INST_LLDBG, bin1logger, 1, (1, 1, 10, buf));
    I don't see any call to LogMsgBuffers here. Is this a macro? Does it expand into a call to LogMsgBuffers()? Can you post its definition and/or expansion?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...