Re: Question on rtems printf problem

2022-12-20 Thread Frank Kühndel

Hello tianye,

On 12/20/22 03:59, tia...@sugon.com wrote:

Hi:
I have a testcode, it will lead to uart print space forever.

Demo code like this:
Init()
{
create a task;
start this task;
*printf("%*\n");* while(1) { sleep() } } This code lead to uart print 
space forever('SPACE' ascii is 0x20): 
'SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE'..


"%*\n" is an illegal or incorrect "conversion specification" because is 
misses an "conversion specifier" (e.g. an "d", "s" or "x" before the 
"\n"). Whether the behavior is a bug depends on the specification of the 
behavior of `printf()` in such a case. I am not aware of any 
specification of what should happen when the "conversion specification" 
is malformed.


I tried with gcc on an ordinary Linux and it printed (to my surprise):

%107348472

The print out of spaces cannot be excused with the presents of a field 
with specifier "*" because without knowing the length of the content of 
the field - due to the missing conversion specifier - the software 
cannot calculate how may spaces to print out.


Anyway, your `printf()` should trigger this compiler warning:

../../../testsuites/samples/hello/init.c:44:14: warning: unknown 
conversion type character '\x0a' in format [-Wformat=]

   44 |   printf( "%*\n" );
  |  ^~

Since the issue appears to be triggered in newlib code, I believe 
changing RTEMS code wont help in any case. Yet, again it is dubious to 
me whether this is a bug in the first place.


Greetings
Frank

--
embedded brains GmbH
Herr Frank KÜHNDEL
Dornierstr. 4
82178 Puchheim
Germany
email: frank.kuehn...@embedded-brains.de
phone:  +49-89-18 94 741 - 23
mobile: +49-176-15 22 06 - 11
fax:+49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Re: Question on rtems printf problem

2022-12-19 Thread tianye
It's just a random string testcase for printf.I know it's not a correct parameter for printf, but this lead to uart print space(ascii:0x20)0 forever.Maybe it's a newlib bug.So, I was wonder who encountered this proble, and how to solve this problem.-gro...@chichak.ca ׫д:-ÊÕ¼þÈË: tia...@sugon.com, "RTEMS List" ·¢¼þÈË: gro...@chichak.caÈÕÆÚ: 2022/12/20 ÏÂÎç01:49Ö÷Ìâ: Re: Question on rtems printf problemOn 2022-December-19, at 19:59, tia...@sugon.com wrote:Hi:	I have a testcode, it will lead to uart print space forever.Demo code like this:	Init()	{		create a task;		start this task;		printf("%*\n");while(1) { 			sleep()		}	}What are you expecting get? The * tells printf that there will be a parameter following that will give you the length of the subsequent parameter. Usually of the format %*s, length, string.I¡¯m pretty sure that you don¡¯t have a proper format string, it¡¯s missing the item that you should be specifying the length for and then you neither have the length nor the item to be printed.What are you trying to do?A
-Andrei Chichak
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Re: Question on rtems printf problem

2022-12-19 Thread groups


> On 2022-December-19, at 19:59, tia...@sugon.com  
> wrote:
> 
> Hi:
>   I have a testcode, it will lead to uart print space forever.
> 
> Demo code like this:
>   Init()
>   {
>   create a task;
>   start this task;
>   printf("%*\n");
> while(1) { 
>   sleep()
>   }
>   }

What are you expecting get? The * tells printf that there will be a parameter 
following that will give you the length of the subsequent parameter. Usually of 
the format %*s, length, string.
I’m pretty sure that you don’t have a proper format string, it’s missing the 
item that you should be specifying the length for and then you neither have the 
length nor the item to be printed.

What are you trying to do?


A


-
Andrei Chichak

___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Re: Question on rtems printf problem

2022-12-19 Thread groups
On 2022-December-19, at 19:59, tia...@sugon.com  wrote:
> 
> Hi:
>   I have a testcode, it will lead to uart print space forever.
> 
> Demo code like this:
>   Init()
>   {
>   create a task;
>   start this task;
>   printf("%*\n");
> while(1) { 
>   sleep()
>   }
>   }

What are you expecting get? The * tells printf that there will be a parameter 
following that will give you the length of the subsequent parameter. Usually of 
the format %*s, length, string.
I’m pretty sure that you don’t have a proper format string, it’s missing the 
item that you should be specifying the length for and then you neither have the 
length nor the item to be printed.

What are you trying to do?


A


-
Andrei Chichak

___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Question on rtems printf problem

2022-12-19 Thread tianye
Hi:	I have a testcode, it will lead to uart print space forever.Demo code like this:	Init()	{		create a task;		start this task;		printf("%*\n");while(1) { 			sleep()		}	}This code lead to uart print space forever('SPACE' ascii is 0x20):	'SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE''SPACE'..zynq qemu backtrace:(gdb) bt#0  zynq_uart_write_polled (base=0x9000a8 , c=32 ' ')    at ../../../../../../../../kernel/c/src/lib/libbsp/arm/xilinx-zynq/../../../../../../bsps/arm/shared/serial/zynq-uart-polled.c:197#1  0x008438b8 in zynq_debug_console_out (c=32 ' ')    at ../../../../../../../../kernel/c/src/lib/libbsp/arm/xilinx-zynq/../../../../../../bsps/arm/xilinx-zynq/console/debug-console.c:41#2  0x0080af54 in rtems_putc (c=32 ' ')    at ../../../../../kernel/c/src/../../cpukit/libcsupport/src/rtems_putc.c:34#3  0x00808a08 in _Console_simple_Write (iop=0x903dc0 , buffer=0x90ea30,    count=1024) at ../../../../../kernel/c/src/../../cpukit/libcsupport/src/consolesimple.c:52#4  0x00845190 in write (fd=1, buffer=0x90ea30, count=1024)    at ../../../../../kernel/c/src/../../cpukit/libcsupport/src/write.c:47#5  0x00844b00 in _write_r (ptr=0x902790 <_RTEMS_tasks_Objects+704>, fd=1, buf=0x90ea30, nbytes=1024)    at ../../../../../kernel/c/src/../../cpukit/libcsupport/src/write_r.c:42#6  0x0083c2bc in __swrite (ptr=ptr@entry=0x902790 <_RTEMS_tasks_Objects+704>,    cookie=0x904608 <__sf+128>, buf=buf@entry=0x90ea30 ' ' ..., n=n@entry=1024)    at ../../../../../gcc-7.5.0/newlib/libc/stdio/stdio.c:94#7  0x00840da4 in __sflush_r (ptr=ptr@entry=0x902790 <_RTEMS_tasks_Objects+704>,    fp=fp@entry=0x904608 <__sf+128>) at ../../../../../gcc-7.5.0/newlib/libc/stdio/fflush.c:224#8  0x00840eb8 in _fflush_r (ptr=ptr@entry=0x902790 <_RTEMS_tasks_Objects+704>,    fp=fp@entry=0x904608 <__sf+128>) at ../../../../../gcc-7.5.0/newlib/libc/stdio/fflush.c:278#9  0x00842490 in __sfvwrite_r (ptr=0x902790 <_RTEMS_tasks_Objects+704>, fp=0x904608 <__sf+128>,    uio=0x907610) at ../../../../../gcc-7.5.0/newlib/libc/stdio/fvwrite.c:232#10 0x00841e78 in __sprint_r (ptr=ptr@entry=0x902790 <_RTEMS_tasks_Objects+704>,    fp=fp@entry=0x904608 <__sf+128>, uio=0x907610, uio@entry=0x907608)    at ../../../../../gcc-7.5.0/newlib/libc/stdio/vfprintf.c:429--Type  for more, q to quit, c to continue without paging--#11 0x00841e88 in __sprint_r (ptr=ptr@entry=0x902790 <_RTEMS_tasks_Objects+704>,    fp=fp@entry=0x904608 <__sf+128>, uio=uio@entry=0x907608)    at ../../../../../gcc-7.5.0/newlib/libc/stdio/vfprintf.c:405#12 0x0083cce4 in _vfprintf_r (data="" out>, fp=, fmt0=fmt0@entry=0x0, ap=...,    ap@entry=...) at ../../../../../gcc-7.5.0/newlib/libc/stdio/vfprintf.c:1681#13 0x0083c110 in printf (fmt=0x8459e8 "k%*\n")    at ../../../../../gcc-7.5.0/newlib/libc/stdio/printf.c:56#14 0x00805834 in Init (argument=) at ../../testsuites/memoryareatest/init.c:66#15 0x00822bdc in _Thread_Entry_adaptor_numeric (executing=0x9024d0 <_RTEMS_tasks_Objects>)    at ../../../../../kernel/c/src/../../cpukit/score/src/threadentryadaptornumeric.c:25#16 0x0081eec0 in _Thread_Handler ()    at ../../../../../kernel/c/src/../../cpukit/score/src/threadhandler.c:139#17 0x00838368 in _Thread_Start_multitasking ()    at ../../../../../kernel/c/src/../../cpukit/score/src/threadstartmultitasking.c:64
___
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users