Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #262581 > unrolled thread
| Started by | tom kronmiller <twk.personal@gmail.com> |
|---|---|
| First post | 2023-10-23 05:00 +0200 |
| Last post | 2023-10-23 05:40 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.debian.user
12.2: fork() causing getline() to repeat stdin endlessly tom kronmiller <twk.personal@gmail.com> - 2023-10-23 05:00 +0200
Re: 12.2: fork() causing getline() to repeat stdin endlessly Stefan Monnier <monnier@iro.umontreal.ca> - 2023-10-23 05:30 +0200
Re: 12.2: fork() causing getline() to repeat stdin endlessly Greg Wooledge <greg@wooledge.org> - 2023-10-23 05:40 +0200
| From | tom kronmiller <twk.personal@gmail.com> |
|---|---|
| Date | 2023-10-23 05:00 +0200 |
| Subject | 12.2: fork() causing getline() to repeat stdin endlessly |
| Message-ID | <HrTkB-bne-1@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
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). Also, will "reportbug" allow me to attach the program and example input to the bug report? Should I post them here? Thanks.
[toc] | [next] | [standalone]
| From | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| Date | 2023-10-23 05:30 +0200 |
| Message-ID | <HrTND-bMD-1@gated-at.bofh.it> |
| In reply to | #262581 |
> 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).
My crystal ball says the most likely culprits are (in order):
- your code.
- POSIX.
- glibc.
- the kernel.
Stefan
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2023-10-23 05:40 +0200 |
| Message-ID | <HrTXj-bPN-1@gated-at.bofh.it> |
| In reply to | #262581 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web