Question regarding "the code can crash inside load_descriptor_values()"

113 views
Skip to first unread message

cptkoolbeenz

unread,
Oct 29, 2020, 2:58:15 AM10/29/20
to nanopb
My pb_encode() call is crashing in  load_descriptor_values().

I noticed this in migration.md:

Error indications: Messages may fail to encode or decode, or the code can crash inside load_descriptor_values() in pb_common.c. 

I'm wondering if this is what I'm seeing and how to debug.  Any insight would be helpful!
Thanks


Petteri Aimonen

unread,
Oct 29, 2020, 3:45:35 AM10/29/20
to nan...@googlegroups.com
Hi,

> I'm wondering if this is what I'm seeing and how to debug. Any insight
> would be helpful!

If you have debugging symbols you can check sizeof(pb_msgdesc_t) in
different files to make sure it is the same.

But the most straightforward way is just to recompile your whole project
(clean all and recompile). The problem only occurs if some .o files are
used between versions without recompiling.

--
Petteri

cptkoolbeenz

unread,
Oct 29, 2020, 4:09:30 PM10/29/20
to nanopb
Hi Petteri
Thank you for your reply and for providing such an excellent project for everyone to use!  I've been using nanopb 0.3.9 but this is the first time using 0.4.3.
I tried cleaning and rerunning the project.  However, it is still crashing on Line 17 in pb_common.h

word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);

I'm using a PIC32MX270F256B and have had no issues prior to 0.4.3 (different projects but the same function calls).
My code snippet is below:

        SubPacket msg = SubPacket_init_zero;
        uint8_t buffer[128];
        pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
        bool status;
        
        const char text[8] = "hi\n";
        
        msg.dest = UINT32_MAX;    // Broadcast address
        msg.which_payload = SubPacket_data_tag;
        memcpy(&msg.data.payload.bytes, &text, sizeof(text));
        msg.data.payload.size = strlen(msg.data.payload.bytes);
        msg.data.typ = Data_Type_CLEAR_TEXT;
             
        status = pb_encode(&stream, SubPacket_fields, &msg);

Obviously, I'm doing something dumb...  just not sure what.
-c

cptkoolbeenz

unread,
Oct 29, 2020, 7:00:10 PM10/29/20
to nanopb
Problem solved!  You were exactly right, my project was referencing some old (externally compiled) object files.  Once I removed the out-of-date compiled library reference, everything works perfectly!
Thanks again.
Chris

Petteri Aimonen

unread,
Oct 30, 2020, 2:58:41 AM10/30/20
to nan...@googlegroups.com
Hi,

Great to hear that you found the problem :)

--
Petteri
> --
> You received this message because you are subscribed to the Google Groups "nanopb" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nanopb+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nanopb/f46876ae-1b4e-4852-bb1f-4b1e069db04dn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages