Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipe ending in function containing pipes causes negotiation failure #88

Closed
lucaswerkmeister opened this issue Aug 9, 2017 · 7 comments
Assignees

Comments

@lucaswerkmeister
Copy link
Contributor

lucaswerkmeister commented Aug 9, 2017

With the following content in the file script,

function g {
    /bin/cat | /bin/cat
}

/bin/cat /dev/null | g

dgsh script results in the following output:

ames@b<U/holocal/bcatcatcat14792 dgsh: timeout for negotiation. Exit.
14794 dgsh: timeout for negotiation. Exit.
14795 dgsh: timeout for negotiation. Exit.

The garbage at the beginning is printed immediately and looks a lot like random memory being dumped. The rest of the output is printed after the five second timeout.

In a similar script, which you can find in this gist, I’ve also encountered an assertion failure:

dgsh-wrap: negotiate.c:2339: read_input_fds: Assertion `this_nc->node_index == self_node.index' failed.
dgsh-conc: exiting before dgsh negotiation is complete
dgsh-tee: negotiate.c:2339: read_input_fds: Assertion `this_nc->node_index == self_node.index' failed.
[the code of the countDescriptions function is interleaved with the output from here on]
15436 Aborted
15437 Segmentation fault
15424 dgsh: timeout for negotiation. Exit.

In both cases, there’s a simple workaround: pipe to cat.

Might be related to or duplicate of #4.

@lucaswerkmeister lucaswerkmeister changed the title Piping to function containing files causes negotiation failure Pipe ending in function containing pipes causes negotiation failure Aug 9, 2017
@dspinellis
Copy link
Owner

IMO this is a bug: dgsh should not have attempted to negotiate.

On the other hand, ou're trying to mix water with oil: having dgsh (rather than bash) execute a script where you've forced commands to be non-dgsh compatible. I assume this is an example of a more complex scenario. What are you trying to achieve?

@mfragkoulis mfragkoulis self-assigned this Aug 10, 2017
@lucaswerkmeister
Copy link
Contributor Author

having dgsh (rather than bash) execute a script where you've forced commands to be non-dgsh compatible.

The same bug occurs with cat instead of /bin/cat (and the printed garbage in that case includes dgsh-tee, so presumably that time it’s using the dgsh version) – I just thought the version without dgsh-aware tools was the simpler one to reproduce the bug.

I assume this is an example of a more complex scenario. What are you trying to achieve?

The more complex scenario is the script (see also the comment on the gist for details) that I shared near the end of the bug (which includes a multipipe); even though the error that occurs is different, both scripts have a pipeline ending in a function, and in both cases the workaround is to append cat to the pipeline, so I suspect it’s the same bug.

@dspinellis
Copy link
Owner

You definitely need cat or a similar gathering command at the end of the multipipe, because summarizeDescriptions cannot accept four inputs, so the negotiation would fail.

@lucaswerkmeister
Copy link
Contributor Author

There already is a cat after the multipipe, but this is the buggy version of the script. The workaround is another cat after summarizeDescriptions.

@mfragkoulis
Copy link
Collaborator

You are right, it should be the same bug. I have tracked it down and I am working on a solution.
Hopefully, I will have it tomorrow.

mfragkoulis added a commit that referenced this issue Aug 11, 2017
so that the first and last command in a function
get correctly any pipe connections to a function call
(pipe_in for first, pipe_out for last)
Add two tests for this
Fix issue #88
@mfragkoulis
Copy link
Collaborator

Does it resolve the bug?

@lucaswerkmeister
Copy link
Contributor Author

Seems to have fixed it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants