lspgn edited a comment on issue #5695: Go: Segfault on messageId serialize 
after getting it from producer
URL: https://github.com/apache/pulsar/issues/5695#issuecomment-561059864
 
 
   I created a branch with more debug:
   
https://github.com/lspgn/pulsar/commit/7d1c0f4c2074f2240b888306822d81092042a490
   
https://github.com/lspgn/pulsar/commit/1373b1b884a6b6822568ca4e931445469683f72f
   
   The following C prints more information about the messageId structure:
   ```
   static int myprint(pulsar_message_id_t* messageId) {
        printf("  messageId: %x\n", messageId);
        char *a = messageId;
        printf("  strlen: %d\n", strlen(a));
        printf("  ");
        for(int i = 0; i < strlen(a);i++) {
                printf("0x%x ", a[i]);
        }
        printf("\n");
        return strlen
   }
   ```
   
   ```
   func (m *messageID) String() string {
        fmt.Printf("messageID String %v\n", m.ptr)
        strl := int(C.myprint(m.ptr))
   
        if strl == 4 {
                str := C.pulsar_message_id_str(m.ptr)
                defer C.free(unsafe.Pointer(str))
                return C.GoString(str)  
        }
        
        return "none"
   }
   ```
   
   The output of this is:
   ```
   
   getMessageId
   messageID String &{}
     messageId: 7811e60
     strlen: 0
   
   The message Id value is: [none]
   getMessageId
   messageID String &{}
     messageId: 6f002a0
     strlen: 0
   
   The message Id value is: [none]
   getMessageId
   messageID String &{}
     messageId: 6f002a0
     strlen: 0
   
   The message Id value is: [none]
   getMessageId
   messageID String &{}
     messageId: 7a086a0
     strlen: 0
   
   The message Id value is: [none]
   getMessageId
   messageID String &{}
     messageId: 6e014c0
     strlen: 3
     0xffffff9f 0x2 0x6e
   The message Id value is: [none]
   getMessageId
   messageID String &{}
     messageId: 6f02a80
     strlen: 4
     0xffffffb8 0x2a 0xfffffff0 0x6
   The message Id value is: [(75556568,0,2433,37)]
   getMessageId
   messageID String &{}
     messageId: 6e00c10
     strlen: 4
     0xffffffc8 0x2b 0xffffffe0 0x6
   The message Id value is: [(75556568,0,2433,37)]
   getMessageId
   messageID String &{}
     messageId: 7812940
     strlen: 0
   
   The message Id value is: [none]
   getMessageId
   messageID String &{}
     messageId: 6e01f40
     strlen: 3
     0xffffffb4 0x2 0x6e
   The message Id value is: [none]
   getMessageId
   messageID String &{}
     messageId: 7a086a0
     strlen: 0
   
   ```
   It seems to only work when the length of the ID is 4 bytes. Otherwise it 
fails to convert to a proper ID.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to