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

[RDY] Job control fixes and pseudo terminal support #2037

Merged
merged 4 commits into from Feb 24, 2015

Conversation

tarruda
Copy link
Member

@tarruda tarruda commented Feb 21, 2015

The end goal is to spawn bang commands connected to pseudo terminals, which will fix issues such as #1716. For windows an alternative implementation of pty_process.c will be required, probably on top of winpty

} UvProcess;

void pipe_process_init(Job *job, char **argv, bool enable_stdin,
bool enable_stdout, bool enable_stderr)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These args could be vertically aligned to help readability. I usually end up doing that if they don't all fit on one line.

@tarruda tarruda force-pushed the job-pty branch 11 times, most recently from 4cc4737 to c3fbf48 Compare February 23, 2015 13:11
@tarruda tarruda changed the title [WIP] Extend job control to support spawning processes via ptys [WIP] Extend job control to support spawning interactive programs Feb 23, 2015
@tarruda tarruda force-pushed the job-pty branch 6 times, most recently from 4606585 to 67f1d1f Compare February 23, 2015 17:02
@tarruda tarruda changed the title [WIP] Extend job control to support spawning interactive programs [WIP] Job control fixes and enhancements Feb 23, 2015
@tarruda tarruda force-pushed the job-pty branch 5 times, most recently from f38eaba to be25111 Compare February 24, 2015 00:18
Job autocommands will no longer buffer data chunks that don't end in newlines
characters.
Send sigterm immediately since it can be caught by processes. If they don't
respond and are still alive after a while, SIGKILL will be sent.
- process spawning was decoupled from the rest of the job control logic.  The
  goal is reusing it for spawning processes connected to pseudo terminal file
  descriptors.
- job_start now receives a JobOptions structure containing all the startup
  options.
@tarruda tarruda changed the title [WIP] Job control fixes and enhancements [RDY] Job control fixes and pseudo terminal support Feb 24, 2015
@tarruda tarruda merged commit d7e560e into neovim:master Feb 24, 2015
@ghost
Copy link

ghost commented Feb 24, 2015

My build is failing with this while linking tty-test:

[224/224] Linking C executable bin/tty-test
FAILED: : && /usr/lib/hardening-wrapper/bin/cc  -Wconversion -g  -Wl,--no-undefined test/functional/job/CMakeFiles/tty-test.dir/tty-test.c.o  -o bin/tty-test  -rdynamic ../.deps/usr/lib/libuv.a -ldl -lnsl -lrt && :
/usr/bin/ld: ../.deps/usr/lib/libuv.a(libuv_la-thread.o): undefined reference to symbol 'pthread_rwlock_trywrlock@@GLIBC_2.2.5'
/usr/lib/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
[224/224] Linking C executable bin/nvim
ninja: build stopped: subcommand failed.
Makefile:52: recipe for target 'nvim' failed
make: *** [nvim] Error 1

I get the error with or without hardening-wrapper, and this is with a clean build. It might have something to do with the fact that I'm on Arch Linux, which uses glibc 2.21

@tarruda
Copy link
Member Author

tarruda commented Feb 24, 2015

@pyrohh strange that you would get this error now, all I did was add a custom executable target for testing the pty integration. What happens if you apply this patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index caf345d..19ed0e7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -276,7 +276,7 @@ get_compile_flags(NVIM_VERSION_CFLAGS)

 add_subdirectory(test/includes)
 add_subdirectory(config)
-add_subdirectory(test/functional/job) # compile pty test program
+# add_subdirectory(test/functional/job) # compile pty test program


 # Setup some test-related bits.  We do this after going down the tree because we

@fwalch
Copy link
Member

fwalch commented Feb 24, 2015

Similar error happens in the Ubuntu PPA build:

make[5]: Leaving directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1/build'
[100%] Built target translations
make[5]: Entering directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1/build'
Scanning dependencies of target tty-test
make[5]: Leaving directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1/build'
make[5]: Entering directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1/build'
[100%] Building C object test/functional/job/CMakeFiles/tty-test.dir/tty-test.c.o
Linking C executable ../../../bin/tty-test
/usr/bin/ld: ../../../../.deps/usr/lib/libuv.a(libuv_la-thread.o): undefined reference to symbol 'pthread_create@@GLIBC_2.1'
/lib/i386-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
test/functional/job/CMakeFiles/tty-test.dir/build.make:86: recipe for target 'bin/tty-test' failed
make[5]: *** [bin/tty-test] Error 1
make[5]: Leaving directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1/build'
CMakeFiles/Makefile2:2807: recipe for target 'test/functional/job/CMakeFiles/tty-test.dir/all' failed
make[4]: *** [test/functional/job/CMakeFiles/tty-test.dir/all] Error 2
make[4]: Leaving directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1/build'
Makefile:117: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1/build'
Makefile:52: recipe for target 'nvim' failed
make[2]: *** [nvim] Error 2
make[2]: Leaving directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1'
dh_auto_build: make -j1 returned exit code 2
debian/rules:4: recipe for target 'override_dh_auto_build' failed
make[1]: *** [override_dh_auto_build] Error 2
make[1]: Leaving directory '/build/buildd/neovim-0.0.0+git201502240125+6~ubuntu15.04.1'
debian/rules:11: recipe for target 'build-arch' failed
make: *** [build-arch] Error 2
dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2

@tarruda
Copy link
Member Author

tarruda commented Feb 24, 2015

undefined reference to symbol 'pthread_create

This error usually happens when linking against libuv without also linking to pthread, which is normally handled by the pkgconfig(or else even the travis build would fail). I have no clue why this error was introduced in the AUR/PPA builds. cc @jszakmeister

@ajpaulson
Copy link

Hi - I'm getting the same issue when doing a build (even a fresh build) on Debian Jessie.

According to the output, pthreads is found:

-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  

I can't find confirmation that it is even attempting to link aside from that.

Linking C executable ../../../bin/tty-test
/usr/bin/ld: ../../../../.deps/usr/lib/libuv.a(libuv_la-thread.o): undefined reference to symbol           'pthread_rwlock_trywrlock@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

@fwalch fwalch mentioned this pull request Feb 24, 2015
@fwalch
Copy link
Member

fwalch commented Feb 24, 2015

The PPA build for 12.04 worked, by the way.. guess that explains why Travis doesn't complain.

@tarruda
Copy link
Member Author

tarruda commented Feb 24, 2015

@fwalch is the build error present before this PR? I ask because I can't see what I could have changed to affect libuv linking

@fwalch
Copy link
Member

fwalch commented Feb 24, 2015

I can't seem to find the revision used to build the packages in the logs :-/ The last successful build was at 2015-02-22 19:55, the one after that is the failing one (there's only one build per day).

There are two different errors for x86 and x64:

x86:

libuv.a(libuv_la-thread.o): undefined reference to symbol 'pthread_create@@GLIBC_2.1'

x64:

libuv.a(libuv_la-thread.o): undefined reference to symbol 'pthread_rwlock_trywrlock@@GLIBC_2.2.5'

Let's maybe move the discussion to #2052? This PR is already closed..

@ajpaulson
Copy link

After running git bisect and double checking manually - the first build breaking commit is:

0b8d3cb

Which breaks with a different error and is fixed in the following commit.

The first commit that breaks with this libuv undefined reference to symbol... error is:

d7e560e

Which is a refactoring commit.

EDIT
After a little searching -
test/functional/job/CMakeLists.txt
has target_link_libraries(tty-test ${LIBUV_LIBRARIES})
I'm wondering if it might need an explicit linkage for pthread?

@jszakmeister
Copy link
Contributor

@tarruda See #2053 and #2054.

@ajpaulson
Copy link

Confirmed fixed on Debian 7

}

if (job->opts.stderr_cb) {
uv_pipe_open(&ptyproc->proc_stderr, dup(master));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverity thinks these 3 dup() calls are leaks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity complains about not closing the (three additional) handles created by dup(master). Closing master won't close these handles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are closed by libuv when the stream is closed: https://github.com/libuv/libuv/blob/v1.x/src/unix/stream.c#L1563-L1568

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

Successfully merging this pull request may close these issues.

None yet

7 participants