Assertion failed: "vsnprintf failed"

Technical questions regarding the XTC tools and programming with XMOS.
nick
Active Member
Posts: 42
Joined: Tue Jan 07, 2020 10:35 am

Assertion failed: "vsnprintf failed"

Post by nick »

Hi,
I porting a C stack on XMOS. I'm stuck because of an error on link.
I think it's the linker because on console I see "Creating myfile.xe" and then it fails with the following error:
"Assertion failed: n <= 20000 && "vsnprintf failed", file ..\xmap\LinkerErrorHandler.cpp, line 31"
I tried to search LinkerErrorHandler.cpp but I didn't find it. So it's seems to be a temporary file that after the failure is deleted.

I also commented all printf in the stack because I thought the error was caused by a printf that was too long or with too many variables.

I don't see errors or warnings that could have caused this message. Any ideas? What can I check?


User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am

Post by mon2 »

Perhaps the docs for the assertion library will help. Try to enable one of the other assertion flags to offer more debug details.

https://github.com/xmos/lib_xassert/blo ... assert.rst
lorenzochiesi
Active Member
Posts: 34
Joined: Mon Sep 05, 2016 4:20 pm

Post by lorenzochiesi »

Hi Nick,

I don't think that "LinkerErrorHandler.cpp" is a temporary file created during the building/linking process on your computer.
It looks to me most likely be a source file of the linker itself, thus why you are not finding it on your computer.
Thus looks like this error come from an assertion failed within the linker process itself for whatever reason.

Anyone ever see this or similar kind of issue?
User avatar
akp
XCore Expert
Posts: 579
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Any hope of posting a minimal implementation that generates this error?
nick
Active Member
Posts: 42
Joined: Tue Jan 07, 2020 10:35 am

Post by nick »

Thanks for your replies.

Here some updates: in the beginning I used xTimeComposer 14.4.1 and it gave the error mentioned above.
Then I tried to compile the stack with xTimeComposer 14.2.3 and surprisingly the error was different (with the same project): version 14.2.3 doesn't finish to compile but it finds some errors of macros and types redefinition.
The strange thing is that I've already compiled this project for another microcontroller, without changing anything. So, I don't understand why XMOS compiler is giving me errors.

It's difficult to post an implementation because (probably) there's something wrong with inclusions.

Another thing I noticed is that XMOS file "stddef.h" defines a different macro respect to what my stack expects (and also respect to "stddef.h" in the other microcontroller I used).
The macro is usually defined as _STDDEF_H but in XMOS is __STDDEF_H. Tried to change it but without success.
nick
Active Member
Posts: 42
Joined: Tue Jan 07, 2020 10:35 am

Post by nick »

I'll try to post some useful code.

In file pb_decode.h:

Code: Select all

#include "pb.h"

struct pb_istream_s
{
#ifdef PB_BUFFER_ONLY
    int *callback;
#else
    bool (*callback)(pb_istream_t *stream, uint8_t *buf, size_t count);
#endif
};
In pb.h:

Code: Select all

typedef struct pb_istream_s pb_istream_t;
In bdd_helper.h:

Code: Select all

#define PB_BUFFER_ONLY 1
One of the errors I got is:
pb_decode.c: Error: Type of symbol pb_istream_from_buffer has mismatch with previous definition:
pb_decode.c: Error: found: struct pb_istream_s { bool *callback(struct pb_istream_s *, unsigned char *, unsigned int); void *state; unsigned int bytes_left; const unsigned char *errmsg; } pb_istream_from_buffer(unsigned char *, unsigned int)
bdd_helper.c: Error: previous: struct pb_istream_s { signed int *callback; void *state; unsigned int bytes_left; const unsigned char *errmsg; } pb_istream_from_buffer(unsigned char *, unsigned int)


So depending if the file bdd_helper.h is included or not, PB_BUFFER_ONLY is defined or not. This cause a different definition of pb_istream_s.
Why on XMOS compiler this is causing problems, while on another is ok?