Commit Graph

6744 Commits

Author SHA1 Message Date
Corinna Vinschen 2cd7eb7f60 Fix original stack when running signal handler on alternate stack
* autoload.cc (SetThreadStackGuarantee): Import.
        * cygtls.h (struct _cygtls): Replace thread_context with a ucontext_t
        called context.
        * exceptions.cc (exception::handle): Exit from process via signal_exit
        in case sig_send returns from handling a stack overflow SIGSEGV.
        Explain why.
        (dumpstack_overflow_wrapper): Thread wrapper to create a stackdump
        from another thread.
        (signal_exit): Fix argument list to reflect three-arg signal handler.
        In case we have to create a stackdump for a stack overflow condition,
        do so from a separate thread.  Explain why.
        (sigpacket::process): Don't run signal_exit on alternate stack.
        (altstack_wrapper): Wrapper function to do stack correction when
        calling the signal handler on an alternate stack to handle a stack
        overflow.  Make sure to have lots of comments.
        (_cygtls::call_signal_handler): Drop local context variable to reduce
        stack pressure.  Use this->context instead.  Change inline assembler
        to call altstack_wrapper.
        (_cygtls::signal_debugger): Accommodate aforementioned change to
        struct _cygtls.
        * tlsoffset.h: Regenerate.
        * tlsoffset64.h: Regenerate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-04 22:49:30 +02:00
Corinna Vinschen e3d345c5c3 Fix fork after recovered stack overflow
* fork.cc (frok::parent): Set stacktop value based on requested stack
	pointer value in child.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-01 15:28:16 +02:00
Corinna Vinschen 0f3e631571 Add comment to sigaltstack to explain setting ss_flags here
* signal.cc (sigaltstack): Add comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-30 20:43:50 +02:00
Corinna Vinschen c2c1b84309 Handle ss_flags value longjmp safe.
* exceptions.cc (_cygtls::call_signal_handler): Drop manipulating
	thread's ss_flags here.  It's not safe against longjmp.
	* signal.cc (sigaltstack): Check if we're running on the alternate
	stack and set ss_flags returned in oss to SS_ONSTACK.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-27 12:08:07 +02:00
Corinna Vinschen ba170254e6 Define larger MINSIGSTKSZ and SIGSTKSZ values for Cygwin
* include/cygwin/signal.h: Revert to define MINSIGSTKSZ and SIGSTKSZ
	here with bigger values to allow _cygtls to reside on signal stack,
	should it turn out to be required at one point.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-26 21:41:26 +02:00
Corinna Vinschen 2ecaa3c176 Fix values returned by getrlimit(RLIMIT_STACK)
* resource.cc (getrlimit): Fix values returned by RLIMIT_STACK.
	Explain why this had to be changed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-26 20:41:54 +02:00
Ken Brown d04fd9d5f7 Complement SIGEV_* enums with macros
* include/cygwin/signal.h (SIGEV_*): Add macros.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-23 10:39:06 +02:00
Corinna Vinschen f4abb28ea8 Don't push on original stack during alternate signal stack setup
* exceptions.cc (_cygtls::call_signal_handler): Drop pushing a register
	on the original stack, it confuses GCC.  Rearrange the assembler code
	so that $rax/$eax is not used by GCC to prepare an argument value.
	Use $rax/$eax without saving.  Drop clearing $rbp/$epb.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-22 13:09:55 +02:00
Corinna Vinschen b6c18f2a64 Safe all clobbered volatile registers when using alternate stack
* exceptions.cc (_cygtls::call_signal_handler): Drop subtracting 16
	bytes from the alternate stack, it's not necessary.  Safe all clobbered
	registers.  Safe one on the orignal stack, the others on the alternate
	stack on both platforms.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-21 13:58:57 +02:00
Corinna Vinschen a88afecce6 ChangeLog entries for Cygwin's alternate signal stack implementation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-20 20:36:16 +02:00
Corinna Vinschen 715ac1e872 Formatting fixes in exceptions.cc
* Makefile.in (install-man): Exclude release subdir from search paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-19 16:12:10 +02:00
Corinna Vinschen 0d3304af38 Disallow installing "man pages" from release subdir
* Makefile.in (install-man): Exclude release subdir from search paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-18 22:04:58 +02:00
Corinna Vinschen 50b00d2b93 Add sethostname
* net.cc (sethostname): New function.
	* common.din (sethostname): Export
	* include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2001.
	(CYGWIN_VERSION_DLL_MINOR): Set to 0.

	* new-features.xml (ov-new): Rename from ov-new1.7.
	(ov-new2.1): Add new section.  Document sethostname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-17 11:11:02 +02:00
Corinna Vinschen 79d65a1ed2 Try to handle concurrent close on socket more gracefully
* fhandler_socket.cc (LOCK_EVENTS): Don't enter critical section with
	invalid mutex handle since then socket has been closed.
	(UNLOCK_EVENTS): Close critical section.
	(fhandler_socket::evaluate_events): Handle calling connect on shutdown
	socket.
	(fhandler_socket::wait_for_events): Try for pthread_testcancel in case
	of WAIT_FAILED.  Try to come up with a better errno in case we waited
	on an invalid handle.
	(fhandler_socket::release_events): Change wsock_mtx and wsock_evt to
	NULL under lock to avoid accessing invalid handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-15 18:29:56 +02:00
Corinna Vinschen 6f9e2f3ed5 Handle more Winsock error codes.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-15 16:17:16 +02:00
Corinna Vinschen 95c5a3f6b7 Don't enforce SA_RESTART in non-main threads
* exceptions.cc (_cygtls::call_signal_handler): Disable enforcing
	SA_RESTART in non-main threads to allow returning with EINTR from
	system calls.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-15 16:15:54 +02:00
Corinna Vinschen b81a830f1a Fix ChangeLog entry 2015-06-11 15:39:34 +02:00
Corinna Vinschen 5979b17401 Bump minor DLL version to 5
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-11 12:59:12 +02:00
Corinna Vinschen 6261fb30a9 Avoid compiler warning in latest patch
* pinfo.cc (_pinfo::cwd): Initialize s to avoid comiler warning.
	(_pinfo::cmdline): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 21:55:11 +02:00
Corinna Vinschen 575ec00a43 Evaluate /proc/$PID/{root,cwd,cmdline} for native processes
* pinfo.cc (_pinfo::root): Fake default root for native processes.
	(open_commune_proc_parms): New helper function to access process
	parameter block.
	(_pinfo::cwd): Fetch missing cwd for native processes from processes
	parameter block.
	(_pinfo::cmdline): Ditto for command line.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 21:48:13 +02:00
Corinna Vinschen 95868172f3 Avoid delays trying to fetch Cygwin info from non-Cygwin processes
* pinfo.cc (_pinfo::commune_request): Don't try to send commune
	requests to non-Cygwin processes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 14:38:30 +02:00
Takashi Yano 511eb2f264 Generate SIGHUP for terminal process group on tty master close
* fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP
	into fhandler_pty_master::close().
	(fhandler_pty_slave::read): Ditto.
	(fhandler_pty_master::close): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 14:07:42 +02:00
Corinna Vinschen 4c3946c350 Bump minor DLL version to 4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-08 13:58:39 +02:00
Corinna Vinschen da1611493a Bump minor DLL version to 3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-06-02 14:10:30 +02:00
Corinna Vinschen 712811e9bb Use NtQueryObject to detect closing the last master handle
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-05-28 16:09:46 +02:00
Takashi Yano 3afe8808b9 * net.cc: Define _NETIOAPI_H_ to accomodate newer w32api.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-05-27 13:30:20 +02:00
Corinna Vinschen 761a123a4f Bump minor DLL version to 2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-05-03 12:28:39 +02:00
Corinna Vinschen d4058c6686 Bump minor DLL version to 1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-30 17:53:15 +02:00
Corinna Vinschen b07326d29e Use all ACEs from original ACL on Samba share
* security.cc (convert_samba_sd): Fix accidental dropping of all
	non-Unix User, non-Unix Group accounts.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-30 17:26:55 +02:00
Corinna Vinschen 49c051c133 Define __s64 and __u64
* include/asm/types.h: Add __s64 and __u64 types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-27 14:40:27 +02:00
Corinna Vinschen 5abb0ed13c Handle unlinking in-use files on virtual drives
* path.cc (path_conv::set_nt_native_path): New function.
        * path.h (path_conv::set_nt_native_path): Add prototype.
        * syscall.cc (try_to_bin): Handle moving files to the recycler
        accessed via a local virtual drive (subst).  Fix a problem renaming
        the file to the unique replacement name on Samba.  Align comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:04:59 +02:00
Corinna Vinschen 4e99630cfd Fix closing too many handles in pty fchown/fchmod
* fhandler_tty.cc (fhandler_pty_slave::fch_close_handles): Don't close
	handles not opened via fhandler_pty_slave::fch_open_handles.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:04:59 +02:00
Takashi Yano c846bca992 Fix OPOST for non-Cygwin pty slaves
* fhandler.h (class fhandler_base): Add virtual function
	get_io_handle_cyg() to get handle from which OPOST-processed output is
	read on PTY master.
	(class fhandler_pty_slave): Add variable output_handle_cyg to store a
	handle to which OPOST-processed output is written. Add two functions,
	i.e., set_output_handle_cyg() and get_output_handle_cyg(), regarding
	variable output_handle_cyg. Now, output_handle is used only by native
	windows program. The data before OPOST-processing is written to
	output_handle and OPOST-processing is applied in the master-side. For a
	cygwin process, OPOST-processing is applied in the slave-side, and the
	data after OPOST-processing is written to output_handle_cyg.
	(class fhandler_pty_master): Add two variables, i.e., io_handle_cyg and
	to_master_cyg, to store handles of a pipe through which OPOST-processed
	output passes. Add pty_master_fwd_thread and function
	pty_master_fwd_thread() for a thread which applies OPOST-processing
	and forwards data from io_handle to to_master_cyg. Add function
	get_io_handle_cyg() regarding variable io_handle_cyg. Now, the pipe
	between io_handle and to_master are used only by native windows program
	for applying OPOST-processing in the master-side. For a cygwin process,
	the pipe between io_handle_cyg and to_master_cyg is used for passing
	through the data which is applied OPOST-processing in the slave-side.
	* fhandler_tty.cc (struct pipe_reply): Add member to_master_cyg.
	(fhandler_pty_master::process_slave_output): Read slave output from
	io_handle_cyg rather than io_handle.
	(fhandler_pty_slave::fhandler_pty_salve): Initialize output_handle_cyg.
	(fhandler_pty_slave::open): Set output_handle_cyg by duplicating handle
	to_master_cyg on PTY master.
	(fhandler_pty_slave::close): Close handle output_handle_cyg.
	(fhandler_pty_slave::write): Write data to output_handle_cyg rather
	than output_handle.
	(fhandler_pty_slave::fch_close_handles): Close handle output_handle_cyg.
	(fhandler_pty_master::fhandler_pty_master): Initialize io_handle_cyg,
	to_master_cyg and master_fwd_thread.
	(fhandler_pty_master::cleanup): Clean up to_master_cyg as well.
	(fhandler_pty_master::close): Print to_master_cyg as well in debug
	message. Terminate master forwarding thread. Close handles
	to_master_cyg and io_handle_cyg.
	(fhandler_pty_master::ioctl): Use io_handle_cyg rather than to_master.
	(fhandler_pty_master::pty_master_thread): Add code for duplicating
	handle to_master_cyg.
	(fhandler_pty_master::pty_master_fwd_thread): New function for a thread
	to forward OPOST-processed data from io_handle to to_master_cyg.  This
	thread applies OPOST-processing to the output of native windows program.
	(::pty_master_fwd_thread): Ditto.
	(fhandler_pty_master::setup): Create a new pipe to pass thruegh OPOST-
	processed output. Create new thread to forward data from io_handle to
	to_master_cyg. Set handle to_master_cyg to tty. Print io_handle_cyg as
	well in debug message. Close handles io_handle_cyg and to_master_cyg in
	case of error.
	(fhandler_pty_master::fixup_after_fork): Set handle to_master_cyg to
	tty. Copy handle to_master_cyg from arch->to_master_cyg.
	(fhandler_pty_master::fixup_after_exec): Clean up to_master_cyg.
	* select.cc: Check handle returned by get_io_handle_cyg() rather than
	get_handle().
	* tty.h (class tty): Add variable _to_master_cyg to store a handle to
	which OPOST-processed data is written. Add two functions,
	to_master_cyg() and set_to_master_cyg(), regarding _to_master_cyg.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:04:24 +02:00
Corinna Vinschen 6d099d5bae Undef basename before defining function.
* path.cc (basename): Undefine basename before defining function to
        avoid type collision with prototype in string.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:03:45 +02:00
Corinna Vinschen e0aa6d23fb Remove Cygwin's libgen.h
* include/libgen.h: Remove in favor of newlib version.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:03:45 +02:00
Corinna Vinschen 5dc398f1d9 Fix broken SID in passwd/group entry for unkown account
* uinfo.cc (pwdgrp::fetch_account_from_windows): Always revert SID
        subauth count after checking for known domain.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:01:53 +02:00
Corinna Vinschen 83b3f891c4 Fix broken PSID problem on cygheap in account handling
* pwdgrp.h: Add comment to explain below change.
        (struct pg_pwd): Convert sid member to BYTE array.
        (struct pg_grp): Ditto.
        * grp.cc (pwdgrp::parse_group): Accommodate above change.
        * passwd.cc (pwdgrp::parse_passwd): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 22:01:53 +02:00
Corinna Vinschen 023be4aedb Don't rely on size argument in shmget call
* shm.cc (shmget): Fetch segment size from server rather than using
	size argument to accommodate existing segments.  Add comment to explain
	why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:59:49 +02:00
Corinna Vinschen 5778304f16 Bump Cygwin version to 2.0.0.
* include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2000.
	(CYGWIN_VERSION_DLL_MINOR): Set to 0.

	* new-features.xml (ov-new2.0): Rename from ov-new1.7.36 and change
	version number to 2.0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:58:33 +02:00
Jon TURNEY bccc0e83e8 Set mcontext.cr2 to the faulting address
* exceptions.cc (call_signal_handler): Set mcontext.cr2 to the
	faulting address.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:58:33 +02:00
Jon TURNEY 9043956ce8 Only construct ucontext for SA_SIGINFO signal handlers
* exceptions.cc (call_signal_handler): Only bother to construct
	the ucontext for signal handlers with SA_SIGINFO set.  Set
	mcontext.oldmask.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:58:32 +02:00
Jon TURNEY 65c071bc4d Initialize context before RtlContextCapture
* exceptions.cc (call_signal_handler): Zero initialize context and set
	context flags, as RlCaptureContext doesn't.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:58:32 +02:00
Corinna Vinschen 19dc6ee82c Call open_null to open fake handle
* fhandler_dsp.cc (fhandler_dev_dsp::open): Call open_null.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:13 +02:00
Corinna Vinschen 853fcd8936 Introduce sidfromuid and sidfromgid
* pwdgrp.h (sidfromuid): New inline function.
	(sidfromgid): Ditto.
	* fhandler_disk_file.cc (fhandler_disk_file::fchown): Use sidfromuid.
	* quotactl.cc (quotactl): Use sidfromuid and sidfromgid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Corinna Vinschen 651bb62ae2 Remove __acl16 from official header
* include/cyggwin/acl.h (struct __acl16): Move from here...
	* sec_acl.cc: ...to here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Corinna Vinschen 84b8db8e7a Remove unused 32/64 bit tty code
* tty.h (class tty): Remove unused 32/64 bit interoperability
	considerations.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Corinna Vinschen 19c6889c37 Raise # of ptys to 128.
* tty.h (NTTYS): Raise to 128.
	* devices.in: Change pty, ptym, and cons expressions accordingly.
	* devices.cc: Regenerate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:12 +02:00
Jon TURNEY 4f28e8a0e5 Compile exceptions.cc with -fno-omit-frame-pointer on x86
Selectively using -fomit-frame-pointer when -O is used doesn't make sense
anymore, apparently since gcc 4.6, -O implies -fomit-frame-pointer.

exceptions.cc must be compiled with -fno-omit-frame-pointer on x86, as it uses
RtlCaptureContext, which requires a frame pointer.

	* Makefile.in : Remove setting -fomit-frame-pointer for compiling
	various files, it is already the default.  Set
	-fno-omit-frame-pointer for exceptions.cc on x86.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:57:11 +02:00
Takashi Yano 252a07b0ad Cygwin hangs up if several keys are typed during outputting a lot of texts.
* fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of
	"readlen" not to use "bytes_in_pipe" value directly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-04-23 21:57:11 +02:00
Jon TURNEY 383ff5fc47 Try to make sure struct _mcontext is 16-byte aligned
On x86_64, RtlCaptureContext() uses fxsave to save FPU/MMX/SSE state.

fxsave requires that the destination address is 16-byte aligned, or it will
fault.

CONTEXT is already annotated __attribute__ ((aligned (16))), do the same with
struct _mcontext.

Rearrange ucontext_t so that it's struct _mcontext element is also correctly
aligned.

	* include/cygwin/signal.h (struct __mcontext): 16-byte align.
	* include/sys/ucontext.h (ucontext_t): Ditto.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-04-23 21:57:11 +02:00