[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 12.2: fork() causing getline() to repeat stdin endlessly



On Sun, Oct 22, 2023 at 10:50:15PM -0400, tom kronmiller wrote:
> I have a small program (extracted from a big program) which reads and
> prints input lines using a loop of getline() calls.  The real input lines
> are all expected to be 52 characters long (+1 for the newline => 53),
> that's what my example data for the small program looks like.  If there is
> no fork() in the loop, it works fine.  Inside the loop if I do a fork() of
> a child which immediately exits (no exec) and waitpid() for it, then the
> program loops forever repeating the beginning portion of stdin.
> 
> I have no idea what package to report the problem against, though it
> doesn't seem to be gcc as I have tried both gcc12 (which comes with debian)
> and gcc13 (which I installed manually).

Without knowing you or your code, I'd have to estimate that the chance
of this being a bug in your code is MUCH higher than the chance of this
being a C compiler bug.

Try to construct a minimal reproducer, and post it here.  Someone may
be able to spot the issue.  The shorter and simpler you can make your
reproducer, the more likely someone will be able to help.

There's also a good chance that the process of constructing the reproducer
will reveal the error to you.  This happens frequently.


Reply to: