Граф коммитов

881 Коммитов

Автор SHA1 Сообщение Дата
zverok bddb31bb37 Documentation improvements for Ruby core
* Top-level `return`;
* Documentation for comments syntax;
* `rescue` inside blocks;
* Enhance `Object#to_enum` docs;
* Make `chomp:` option more obvious for `String#each_line` and
  `#lines`;
* Enhance `Proc#>>` and `#<<` docs;
* Enhance `Processs` class docs.
2019-10-26 14:58:08 +09:00
Nobuyoshi Nakada cbbe198c89
Fix potential memory leaks by `rb_imemo_tmpbuf_auto_free_pointer`
This function has been used wrongly always at first, "allocate a
buffer then wrap it with tmpbuf".  This order can cause a memory
leak, as tmpbuf creation also can raise a NoMemoryError exception.
The right order is "create a tmpbuf then allocate&wrap a buffer".
So the argument of this function is rather harmful than just
useless.

TODO:
* Rename this function to more proper name, as it is not used
  "temporary" (function local) purpose.
* Allocate and wrap at once safely, like `ALLOCV`.
2019-10-05 03:02:09 +09:00
Alan Wu 5be2af5f90 Remove call-seq for method that doesn't exist (#2521)
```
$ ruby -ve 'IO.popen("ls"){}; $?.to_int'
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin18]
Traceback (most recent call last):
-e:1:in `<main>': undefined method `to_int' for #<Process::Status: pid 33989 SIGPIPE (signal 13)> (NoMethodError)
Did you mean?  to_i
               taint
```

Process::Status#to_int was removed at 7ba5c4e.
2019-10-04 10:15:24 +09:00
yuuji.yaginuma 0036aa3532 Add version that FreeBSD supports `CLOCK_PROCESS_CPUTIME_ID` [ci skip]
Seems FreeBSD already supported `CLOCK_PROCESS_CPUTIME_ID`.
That added by https://reviews.freebsd.org/rS239347 and the doc was updated
by https://reviews.freebsd.org/rS315694.

I confirmed `CLOCK_PROCESS_CPUTIME_ID` constant exists in 9.3.0 branch.
https://github.com/freebsd/freebsd/blob/release/9.3.0/sys/sys/time.h#L269
2019-09-05 22:09:15 +09:00
卜部昌平 0766f67168 move docs around [ci skip]
To properly generate documents.
2019-08-29 18:34:09 +09:00
卜部昌平 7bcfd9189a drop-in type check for rb_define_global_function
We can check the function pointer passed to rb_define_global_function
like we do so in rb_define_method.  It turns out that almost anybody
is misunderstanding the API.
2019-08-29 18:34:09 +09:00
卜部昌平 7b6fde4258 drop-in type check for rb_define_module_function
We can check the function pointer passed to rb_define_module_function
like how we do so in rb_define_method.  The difference is that this
changeset reveales lots of atiry mismatches.
2019-08-29 18:34:09 +09:00
卜部昌平 1663d347c9 delete `$` sign from C identifiers
They lack portability. See also
https://travis-ci.org/shyouhei/ruby/jobs/577164015
2019-08-27 15:52:26 +09:00
卜部昌平 ae2dc3f217 rb_define_hooked_variable now free from ANYARGS
After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  This commit uses rb_gvar_getter_t /
rb_gvar_setter_t for rb_define_hooked_variable /
rb_define_virtual_variable which revealed lots of function prototype
inconsistencies.  Some of them were literally decades old, going back
to dda5dc00cf.
2019-08-27 15:52:26 +09:00
卜部昌平 5e86b005c0 uid_t and gid_t are narrower than VALUE.
Often uid / gid are 16 bit or 32 bit integers, while VALUE are 32
to 64 bits.  They tend to differ in size.  Because rb_ensure expects
its callbacks to take VALUE arguments, narrowing must be done by
hand, otherwise data corruption can happen depending on machine ABI.
2019-08-26 13:01:58 +09:00
Nobuyoshi Nakada fa6c1b06ad
Suppress a "clobbered" warning 2019-08-26 12:00:19 +09:00
Nobuyoshi Nakada d45d448d71
nil as the default of optional parameters 2019-07-16 21:38:25 +09:00
Nobuyoshi Nakada d8e23a67c3
nil as the default of optional parameters 2019-07-16 19:27:22 +09:00
Nobuyoshi Nakada e988048e25
Moved the check for `exception` to rb_execarg_addopt
Check for `exception` option in rb_execarg_addopt, as well as
other options.  And then raise a particular ArgumentError if it is
not allowed.
2019-07-16 18:57:08 +09:00
Yusuke Endoh b4975693ed process.c (p_sys_setregid, p_sys_setresgid): remove unused tmp buffer
To suppress Coverity Scan warning
2019-07-15 00:07:32 +09:00
nobu 721be15494 process.c: [DOC] remove extra quotes [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-30 12:37:23 +00:00
nobu fcf60d3977 process.c: [DOC] fix markups [ci skip]
* process.c (rb_f_spawn): fix markups as rdoc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-29 01:26:23 +00:00
nobu b9ad698c87 process.c: [DOC] fix markups [ci skip]
* process.c (rb_clock_getres): fix code markups, as `+` can not
  include parentheses.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-29 00:59:34 +00:00
nobu de0ef1a9df [DOC] fix markups [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-28 03:33:35 +00:00
akr b1cb15c4a4 new constant: Process::CLOCK_TAI.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-09 14:54:54 +00:00
stomar 1c53f86bd9 process.c: [DOC] small improvements
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-20 15:07:17 +00:00
k0kubun 56bf732aaf mjit.c: use boolean type for boolean variables
and functions to clarify the intention and make sure it's not used in a
surprising way (like using 2, 3, ... other than 0, 1 even while it seems
to be a boolean).

This is a retry of r66775. It included some typos...

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10 14:31:18 +00:00
k0kubun efd99b5331 Revert "mjit.c: use boolean type for boolean variables"
This reverts commit bb1a1aeab0.

We hit something on ci.rvm.jp, reverting until investigation is done.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10 13:29:29 +00:00
k0kubun bb1a1aeab0 mjit.c: use boolean type for boolean variables
and functions to clarify the intention and make sure it's not used in a
surprising way (like using 2, 3, ... other than 0, 1 even while it seems
to be a boolean).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-10 13:21:58 +00:00
k0kubun 9f3585afad process.c: document system(..., exception: true) [ci skip]
From: Victor Shepelev <zverok.offline@gmail.com>

[Bug #15480]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-29 11:04:42 +00:00
nobu 8ef2aae2d0 Use idException
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22 10:23:06 +00:00
nobu b0ec083a20 process.c (retry_fork_async_signal_safe): fix -Wclobbered
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-04 01:41:55 +00:00
normal 7712ffc7ee process.c (retry_fork_async_signal_safe): fix -Wclobbered on i686
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03 21:00:32 +00:00
normal a226434206 process.c: fix ETXTBUSY from MJIT compiler process
This affects test/ruby/test_process.rb (test_execopt_env_path).

Since MJIT uses vfork+execve in a separate thread, there can be
small window in-between vfork and execve where tmp_script.cmd is
held open by the vforked child.  vfork only pauses the MJIT
thread, not any Ruby Threads, so our call to Process.spawn will
hit ETXTBUSY in that window unless we fork.

main thread                       | MJIT thread
----------------------------------------------------
fd = open(tmp)                    |                |
                                  | vfork for CC   |   CC running
write                             |                | ---------------
fchmod                            |                |  sees "fd" here
close(fd)                         |                |
    Process.spawn called          |                |
vfork  (spawn)|    (new process)  |                |
              | execve => TXTBUSY |                |
              |                   |                | execve (FD_CLOEXEC on fd)
              |                   | vfork returns  |

Holding the waitpid_lock whenever we intend to spawn a process
prevents the MJIT thread from spawning a process while we are
spawning in Ruby-land.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03 19:49:54 +00:00
normal f8c15d0bc7 process.c (rb_execarg_init): mark as static
io.c has not used it since r36229, and we can re-export
it if we need it at another time.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03 09:15:16 +00:00
normal 323ddfc168 process.c (rb_f_system): cleanup to use rb_execarg_get
TypedData_* macros hide assignments and are confusing and too
long for users of giant fonts.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03 08:57:15 +00:00
k0kubun 98a2b053f8 process.c: avoid dlclose before exec
because JIT-ed code may still be on stack at this time, unlike
in ruby_cleanup().

This hopes to fix: (take 2)
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480207

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 15:12:31 +00:00
k0kubun 5b12501163 Revert "process.c: try to workaroun SEGV by r65994"
This reverts commit 0e6aba22c6.

because it didn't help, at all.
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480207

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 15:12:30 +00:00
k0kubun 0e6aba22c6 process.c: try to workaroun SEGV by r65994
http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/1480173

It tries to print C backtrace but fails. And core file on the server
seems to be stopping on the irrelevant place due to its own signal
handler for the dump.

And I failed to reproduce this SEGV on my machine.

I don't know why it's broken, so let me try this change to investigate
the reason of SEGV.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 14:45:39 +00:00
k0kubun 08e1705eec process.c: finish MJIT prior to #exec
to prevent ruby from leaving MJIT-related files.

test_jit.rb: add a test to prevent that

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26 13:39:53 +00:00
normal 6a65f2b1e4 io + socket: make pipes and sockets nonblocking by default
All normal Ruby IO methods (IO#read, IO#gets, IO#write, ...) are
all capable of appearing to be "blocking" when presented with a
file description with the O_NONBLOCK flag set; so there is
little risk of incompatibility within Ruby-using programs.

The biggest compatibility risk is when spawning external
programs.  As a result, stdin, stdout, and stderr are now always
made blocking before exec-family calls.

This change will make an event-oriented MJIT usable if it is
waiting on pipes on POSIX_like platforms.

It is ALSO necessary to take advantage of (proposed lightweight
concurrency (aka "auto-Fiber") or any similar proposal for
network concurrency: https://bugs.ruby-lang.org/issues/13618

Named-pipe (FIFO) are NOT yet non-blocking by default since
they are rarely-used and may introduce compatibility problems
and extra syscall overhead for a common path.

Please revert this commit if there are problems and if I am afk
since I am afk a lot, lately.

[ruby-core:89950] [Bug #14968]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22 08:46:51 +00:00
k0kubun 3405411cc4 process.c: do not try to pause MJIT
while child handler is disabled.

trying to fix [Bug #15320]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 00:04:19 +00:00
k0kubun 27322735af revert r65807
it didn't work.
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468677

and skips broken tests for now. But this issue should be fixed soon.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-19 22:10:12 +00:00
k0kubun e205cd80d2 process.c: do not run signal handler before fork
to prevent from proceeding one for MJIT while it's not safe yet.
By that situation, MJIT worker could be waiting for compiler process forever
http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468033

[Bug #15320]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-19 13:33:07 +00:00
svn 57efe84b13 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-18 08:25:54 +00:00
k0kubun fe6974a8fc mjit_worker.c: support MJIT in forked Ruby process
by launching MJIT worker thread in child Ruby process.

See the comment before `mjit_child_after_fork` for details.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-18 08:25:48 +00:00
ko1 8f675cdd00 support theap for T_HASH. [Feature #14989]
* hash.c, internal.h: support theap for small Hash.
  Introduce RHASH_ARRAY (li_table) besides st_table and small Hash
  (<=8 entries) are managed by an array data structure.
  This array data can be managed by theap.
  If st_table is needed, then converting array data to st_table data.

  For st_table using code, we prepare "stlike" APIs which accepts hash value
  and are very similar to st_ APIs.

  This work is based on the GSoC achievement
  by tacinight <tacingiht@gmail.com> and refined by ko1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 22:11:51 +00:00
normal f7c0cc3692 process.c: implement rb_f_system without toggling ruby_nocldwait
Following how mjit_worker.c currently works, rb_f_system
now ensures the VM-wide waitpid lists is locked before
creating a new process via fork/vfork.

This ensures other rb_waitpid callers cannot steal work and
there are no possible race conditions from toggling
ruby_nocldwait without the use of atomics.

This sets us up for implementing MJIT process management
logic using normal Ruby APIs prepares us for VM-wide
asynchronous/event-base waitpid which can allow MJIT to
work without worker threads.

Take 2: set waitpid_state.pid on platforms w/o fork.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 01:34:48 +00:00
normal fbee3b8f75 revert r65434
http://mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20181030T003541Z.fail.html.gz
I have no chance of getting anything to work on proprietary platforms :<

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30 01:12:38 +00:00
svn 76f08cec20 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29 23:52:45 +00:00
normal 8227c91dfe process.c: implement rb_f_system without toggling ruby_nocldwait
Following how mjit_worker.c currently works, rb_f_system
now ensures the VM-wide waitpid lists is locked before
creating a new process via fork/vfork.

This ensures other rb_waitpid callers cannot steal work and
there are no possible race conditions from toggling
ruby_nocldwait without the use of atomics.

This sets us up for implementing MJIT process management
logic using normal Ruby APIs prepares us for VM-wide
asynchronous/event-base waitpid which can allow MJIT to
work without worker threads.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-29 23:52:39 +00:00
normal 98d0ccc86a rb_sigwait_sleep: change internal API to use rb_hrtime_t
rb_hrtime_t is a more pleasant type to use and this can make
future changes around sleeping/scheduling easier.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 20:14:41 +00:00
stomar 580a210350 process.c: [DOC] improve docs for Process.groups
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 20:01:52 +00:00
svn 9d7a5a493f * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-10 04:20:21 +00:00
ko1 eed1deecba revisit `RARRAY_PTR()`.
* process.c (check_exec_redirect): use RARRAY_AREF() instead of
  using RARRAY_PTR().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-10 04:20:17 +00:00