message_test fails on powerpc and i386

27 views
Skip to first unread message

Elimar Riesebieter

unread,
Jan 14, 2020, 8:44:12 AM1/14/20
to vim...@googlegroups.com
Hi all,

message_test fails on powerpc and i386 (32bit arch):

message_test: message_test.c:170: void test_vim_snprintf(void): Assertion `n == 6' failed.
Aborted
make[1]: *** [Makefile:2242: run_message_test] Error 1

Building on amd64 just runs fine.


Elimar
--
Never make anything simple and efficient when a way
can be found to make it complex and wonderful ;-)

Bram Moolenaar

unread,
Jan 14, 2020, 1:06:19 PM1/14/20
to vim...@googlegroups.com, Elimar Riesebieter

Elimar Riesebieter wrote:

> message_test fails on powerpc and i386 (32bit arch):
>
> message_test: message_test.c:170: void test_vim_snprintf(void): Assertion `n == 6' failed.
> Aborted
> make[1]: *** [Makefile:2242: run_message_test] Error 1
>
> Building on amd64 just runs fine.

This should not be platform-dependent. In the build where it fails, can
you try:
:echo printf("-%06b-", 12)

What does it show?

Unfortunately assert() doesn't show what the actual value was. You
could add a printf() to show it.

--
A disclaimer for the disclaimer:
"and before I get a huge amount of complaints , I have no control over the
disclaimer at the end of this mail :-)" (Timothy Aldrich)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Elimar Riesebieter

unread,
Jan 14, 2020, 1:31:59 PM1/14/20
to vim...@googlegroups.com
* Bram Moolenaar <Br...@moolenaar.net> [2020-01-14 19:06 +0100]:

>
> Elimar Riesebieter wrote:
>
> > message_test fails on powerpc and i386 (32bit arch):
> >
> > message_test: message_test.c:170: void test_vim_snprintf(void): Assertion `n == 6' failed.
> > Aborted
> > make[1]: *** [Makefile:2242: run_message_test] Error 1
> >
> > Building on amd64 just runs fine.
>
> This should not be platform-dependent. In the build where it fails, can
> you try:
> :echo printf("-%06b-", 12)
>
> What does it show?

-001100-

> Unfortunately assert() doesn't show what the actual value was. You
> could add a printf() to show it.

Elimar

--
>what IMHO then?
IMHO - Inhalation of a Multi-leafed Herbal Opiate ;)
--posting from alex in debian-user--

Dominique Pellé

unread,
Jan 14, 2020, 2:22:51 PM1/14/20
to vim_dev
Bram Moolenaar <Br...@moolenaar.net> wrote:

> Elimar Riesebieter wrote:
>
> > message_test fails on powerpc and i386 (32bit arch):
> >
> > message_test: message_test.c:170: void test_vim_snprintf(void): Assertion `n == 6' failed.
> > Aborted
> > make[1]: *** [Makefile:2242: run_message_test] Error 1
> >
> > Building on amd64 just runs fine.
>
> This should not be platform-dependent. In the build where it fails, can
> you try:
> :echo printf("-%06b-", 12)
>
> What does it show?
>
> Unfortunately assert() doesn't show what the actual value was. You
> could add a printf() to show it.

I can reproduce the assert failure after
building vim-8.2.116 with -m32 to build
for 32-bits x86 (after adding a few :i386 ubuntu
packages).

:echo printf("-%06b-", 12)
-001100-

The output looks as expected at least.
But the test fails indeed:

message_test: message_test.c:170: test_vim_snprintf: Assertion `n == 6' failed.

Putting the following fprintf just before that assert...

fprintf(stderr, "*** n=%d bsize=%d buf=[%s]\n", n, bsize, buf);

It shows:

*** n=63 bsize=0 buf=[]

Value of n is completely wrong!?
The recently added test in vim-8.2.66 finds a bug.

I will debug it soon.

Dominique

Bram Moolenaar

unread,
Jan 14, 2020, 2:23:50 PM1/14/20
to vim...@googlegroups.com, Elimar Riesebieter

Elimar Riesebieter wrote:

> > > message_test fails on powerpc and i386 (32bit arch):
> > >
> > > message_test: message_test.c:170: void test_vim_snprintf(void): Assertion `n == 6' failed.
> > > Aborted
> > > make[1]: *** [Makefile:2242: run_message_test] Error 1
> > >
> > > Building on amd64 just runs fine.
> >
> > This should not be platform-dependent. In the build where it fails, can
> > you try:
> > :echo printf("-%06b-", 12)
> >
> > What does it show?
>
> -001100-

That is correct. So why does the test fail?

--
Corn oil comes from corn and olive oil comes from olives, so where
does baby oil come from?

Dominique Pellé

unread,
Jan 14, 2020, 3:19:50 PM1/14/20
to vim_dev
I see why the test fails. The test at message_test.c:169 calls:

169 n = vim_snprintf(buf, bsize, fmt_06b, 12);

So the vararg 12 is an int (32-bits).

The vararg value corresponding to %b is found using
va_arg(ap, uvarnumber_T) at message.c:4540:

4533 else if (fmt_spec == 'b' || fmt_spec == 'B')
4534 {
4535 bin_arg =
4536 # if defined(FEAT_EVAL)
4537 tvs != NULL ?
4538
(uvarnumber_T)tv_nr(tvs, &arg_idx) :
4539 # endif
!!4540 va_arg(ap, uvarnumber_T);
4541 if (bin_arg != 0)
4542 arg_sign = 1;
4543 }

There is a type mismatch between value 12 (an int) and expected
type uvarnumber_T which is a uint64_t (actually the type can depend
on platform and on whether FEAT_NUM64 is defined).

Adding a cast in the test fixes it.
See attached patch fix-message-test.patch.

Regards
Dominique
fix-message-test.patch
Reply all
Reply to author
Forward
0 new messages