On 04/01/2023 14:10, Herbert Xu wrote:
On Wed, Jan 04, 2023 at 11:25:09AM +0000, Harald van Dijk wrote:
Since the only case where special care is needed is when the problematic
token was newline, it can be handled as simply as
if (lasttoken != TNL)
skipline();
You're assuming that the only way of exiting the parser is
through synerror. That's not the case. We could also exit
through sh_error, e.g., if ckmalloc runs out of memory.
In theory, yes. In practice, because of the default Linux overcommit
behaviour, that is not going to happen, that's going to cause the OOM
killer to kick in and forcibly kill the whole process without any way of
handling it. Either that, or forcibly kill some other process that we
get no indication of.
Even if we change the overcommit settings, I'm struggling to think of
any situation where parsing fails because we run out of memory, but
freeing the memory we've already allocated for parsing that one line of
input frees enough to allow us to meaningfully continue.
Cheers,
Harald van Dijk