Assertion failed: "vsnprintf failed"

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
nick
Active Member
Posts: 41
Joined: Tue Jan 07, 2020 10:35 am

Assertion failed: "vsnprintf failed"

Postby nick » Wed Oct 07, 2020 7:43 am

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: 1876
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Wed Oct 07, 2020 2:00 pm

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: 32
Joined: Mon Sep 05, 2016 4:20 pm

Postby lorenzochiesi » Thu Oct 08, 2020 10:44 am

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
Respected Member
Posts: 478
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Wed Oct 28, 2020 4:53 pm

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

Postby nick » Tue Nov 03, 2020 10:13 am

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: 41
Joined: Tue Jan 07, 2020 10:35 am

Postby nick » Tue Nov 03, 2020 1:24 pm

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?

Who is online

Users browsing this forum: No registered users and 5 guests