Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

<Overfiend> Joy: Hey, I'm an asshole. Assholes emit odious gas. That's what we do.


devel / comp.arch.embedded / Re: Worst case stack

SubjectAuthor
* Worst case stackpozz
+* Re: Worst case stackPaul Rubin
|`- Re: Worst case stackDavid Brown
`* Re: Worst case stackClifford Heath
 `- Re: Worst case stackpozz

1
Worst case stack

<sn3anb$9ad$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=717&group=comp.arch.embedded#717

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pozzu...@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: Worst case stack
Date: Wed, 17 Nov 2021 17:30:35 +0100
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <sn3anb$9ad$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 17 Nov 2021 16:30:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="78d595778016f4ecdb8161a6b0f34334";
logging-data="9549"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ygdPLjkXECJP24QO78gz7nLm5NmL+U8Q="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Cancel-Lock: sha1:vs29hwWwtJbVd9hjnfawuDvEuXA=
 by: pozz - Wed, 17 Nov 2021 16:30 UTC

I found a nice tool[1] on GitHub.

I run it on one of my embedded projects and after a couple[2] of fixes,
it eventually printed some good output.

There were many unresolved functions, mainly from libc, C runtime,
interrupts. I defined all of them in .msu, so now in the final output
there aren't unresolved functions.

Now there's another big problem. Many functions have an unbounded stack
usage and I'm quite sure this depends on function pointers.

For example, I use this[3] printf library. It uses function pointer to
emit characters: sprintf calls _vsnprintf() with _out_buffer() function
pointer; printf calls _vsnprintf() with _out_char() function pointer.

So sprintf-like functions have an unbounded stack usage, because the
poor tool wcs.py isn't able to understand that there are only a few
possibilities for the first argument (the function pointer) of _vsnprintf().

It's a pity it isn't possible to set a list of functions for certain
functions pointers so wcs.py could print a better result.

[1] https://github.com/PeterMcKinnis/WorstCaseStack

[2] The tool emitted some errors on a few WEAK functions that are
interrupt handlers. I used .msu file to set a stack usage for those.

Another problem is in print_all_fxns() function and the access to
fxn_dict2['demangledName'].
For some functions (I think the functions defined in .msu) there weren't
'demangledName' so I print the simple 'name'.

[3] https://github.com/mpaland/printf

Re: Worst case stack

<87czmyv855.fsf@nightsong.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=718&group=comp.arch.embedded#718

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: no.em...@nospam.invalid (Paul Rubin)
Newsgroups: comp.arch.embedded
Subject: Re: Worst case stack
Date: Wed, 17 Nov 2021 12:28:54 -0800
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <87czmyv855.fsf@nightsong.com>
References: <sn3anb$9ad$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="55c7780f663b9d5c5067410ce1503f09";
logging-data="19851"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19aPSK3TXxJrDjbxZbIhHmP"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:7qQmyS4ZiTiVtrNMTDxRin/Nzmo=
sha1:dbDCgH4Jk+vt7NqnICJKwzC+2RM=
 by: Paul Rubin - Wed, 17 Nov 2021 20:28 UTC

pozz <pozzugno@gmail.com> writes:
> It's a pity it isn't possible to set a list of functions for certain
> functions pointers so wcs.py could print a better result.

I think MISRA C disallows function pointers, partly for this reason.

Re: Worst case stack

<16b878c7b381d580$1$3213637$e0ddea62@news.thecubenet.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=719&group=comp.arch.embedded#719

  copy link   Newsgroups: comp.arch.embedded
Subject: Re: Worst case stack
Newsgroups: comp.arch.embedded
References: <sn3anb$9ad$1@dont-email.me>
From: no.s...@please.net (Clifford Heath)
Date: Thu, 18 Nov 2021 10:21:02 +1100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <sn3anb$9ad$1@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Message-ID: <16b878c7b381d580$1$3213637$e0ddea62@news.thecubenet.com>
Lines: 29
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!news.thecubenet.com!not-for-mail
NNTP-Posting-Date: Wed, 17 Nov 2021 23:21:03 +0000
X-Received-Bytes: 1797
X-Complaints-To: abuse@thecubenet.com
Organization: theCubeNet - www.thecubenet.com
 by: Clifford Heath - Wed, 17 Nov 2021 23:21 UTC

On 18/11/21 3:30 am, pozz wrote:
> I found a nice tool[1] on GitHub.
>
> I run it on one of my embedded projects and after a couple[2] of fixes,
> it eventually printed some good output.
>
> There were many unresolved functions, mainly from libc, C runtime,
> interrupts. I defined all of them in .msu, so now in the final output
> there aren't unresolved functions.
>
> Now there's another big problem. Many functions have an unbounded stack
> usage and I'm quite sure this depends on function pointers.
>
> For example, I use this[3] printf library. It uses function pointer to
> emit characters: sprintf calls _vsnprintf() with _out_buffer() function
> pointer; printf calls _vsnprintf() with _out_char() function pointer.
>
> So sprintf-like functions have an unbounded stack usage, because the
> poor tool wcs.py isn't able to understand that there are only a few
> possibilities for the first argument (the function pointer) of
> _vsnprintf().
>
> It's a pity it isn't possible to set a list of functions for certain
> functions pointers so wcs.py could print a better result.

It's not just function pointers (in fact the printf thing should be
resolvable), it's recursion, alloca(), variable-sized arrays (a gcc
extension), and other things. In general it is not a computable problem.

Re: Worst case stack

<sn50ds$hi6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=720&group=comp.arch.embedded#720

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: pozzu...@gmail.com (pozz)
Newsgroups: comp.arch.embedded
Subject: Re: Worst case stack
Date: Thu, 18 Nov 2021 08:47:08 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <sn50ds$hi6$1@dont-email.me>
References: <sn3anb$9ad$1@dont-email.me>
<16b878c7b381d580$1$3213637$e0ddea62@news.thecubenet.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 18 Nov 2021 07:47:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3d829fb3e17ff69060ac30b30f2cf54e";
logging-data="17990"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1964TGyapcK1hTzkDuuy0n9Zmi8+nC0fuo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Cancel-Lock: sha1:7LAlZ6AepDqx7d0BYofwSJ7+gmI=
In-Reply-To: <16b878c7b381d580$1$3213637$e0ddea62@news.thecubenet.com>
 by: pozz - Thu, 18 Nov 2021 07:47 UTC

Il 18/11/2021 00:21, Clifford Heath ha scritto:
> On 18/11/21 3:30 am, pozz wrote:
>> I found a nice tool[1] on GitHub.
>>
>> I run it on one of my embedded projects and after a couple[2] of
>> fixes, it eventually printed some good output.
>>
>> There were many unresolved functions, mainly from libc, C runtime,
>> interrupts. I defined all of them in .msu, so now in the final output
>> there aren't unresolved functions.
>>
>> Now there's another big problem. Many functions have an unbounded
>> stack usage and I'm quite sure this depends on function pointers.
>>
>> For example, I use this[3] printf library. It uses function pointer to
>> emit characters: sprintf calls _vsnprintf() with _out_buffer()
>> function pointer; printf calls _vsnprintf() with _out_char() function
>> pointer.
>>
>> So sprintf-like functions have an unbounded stack usage, because the
>> poor tool wcs.py isn't able to understand that there are only a few
>> possibilities for the first argument (the function pointer) of
>> _vsnprintf().
>>
>> It's a pity it isn't possible to set a list of functions for certain
>> functions pointers so wcs.py could print a better result.
>
> It's not just function pointers (in fact the printf thing should be
> resolvable), it's recursion, alloca(), variable-sized arrays (a gcc
> extension), and other things. In general it is not a computable problem.

Yes, in general there are many obstacles to calculate analitically the
worst case stack usage.

Howevere I was talking of *my* project where I don't use recursion,
alloca() and so on. I'm quite sure the only problem is with function
pointers and it's a pity it's not possible to say those kind of tools
which values certain function pointers could have, so it could be able
to calc the worst case precisily.

Re: Worst case stack

<sn55l3$hg0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=722&group=comp.arch.embedded#722

  copy link   Newsgroups: comp.arch.embedded
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.arch.embedded
Subject: Re: Worst case stack
Date: Thu, 18 Nov 2021 10:16:19 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <sn55l3$hg0$1@dont-email.me>
References: <sn3anb$9ad$1@dont-email.me> <87czmyv855.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 18 Nov 2021 09:16:19 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="eacba1fa919d2d9944baf4e35984ee78";
logging-data="17920"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Y9W1OvePAT/V0v7Bo9YrZ5E2NWna09+A="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:OFKDylqcvE37jfsVqLRDLxZprew=
In-Reply-To: <87czmyv855.fsf@nightsong.com>
Content-Language: en-GB
 by: David Brown - Thu, 18 Nov 2021 09:16 UTC

On 17/11/2021 21:28, Paul Rubin wrote:
> pozz <pozzugno@gmail.com> writes:
>> It's a pity it isn't possible to set a list of functions for certain
>> functions pointers so wcs.py could print a better result.
>
> I think MISRA C disallows function pointers, partly for this reason.
>

MISRA C contains no such rule, as far as I could see (in MISRA C 2012).
It has some rules about what you can do with function pointers, but
they are just some of the pointless "you have to write valid C" rules.

Function pointers are a tool that can be very useful for reducing
inter-dependency between different modules. But they should be avoided
where they are not needed, as they have a lot of disadvantages. They
are easy to get wrong, and hard for tools to check automatically. Stack
analysis tools are one example here, as are other tools for flow
analysis (such as doxygen-generated call graphs) - it's also hard to
follow them manually to see when a function might be called if it is
used via function pointers. (They can also be less efficient in use, as
the compiler knows less about them.)

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor