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

117 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 2e7e153a2a [Bug #19242] Prohibit circular causes to be loaded 2022-12-20 14:12:38 +09:00
Nobuyoshi Nakada 67d0f4821f [Bug #19145] `volatile` on an argument may not be effective 2022-11-25 15:50:06 +09:00
Nobuyoshi Nakada 5b959e238e [Bug #19016] re-order error handling at cleanup
Build and store the error message with `#detailed_message` before
terminating all Ractors, then show the message later.
2022-11-22 00:33:19 +09:00
Nobuyoshi Nakada 12b7b85227
Use `enum ruby_tag_type` over `int` 2022-11-20 20:00:40 +09:00
S-H-GAMELINKS 1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Yusuke Endoh eda10e8102 Remove unneeded newline from detailed_message 2022-02-22 11:55:40 +09:00
Yusuke Endoh 35ff545bb6 Exception#detailed_message is added
Also, the default error printer and Exception#full_message use the
method instead of `Exception#message` to get the message string.

`Exception#detailed_message` calls `Exception#message`, decorates and
returns the result. It adds some escape sequences to highlight, and the
class name of the exception to the end of the first line of the message.

[Feature #18370]
2022-02-22 11:55:40 +09:00
Yusuke Endoh 3af316fa8c Refactor out rb_decorate_message from print_errinfo
rb_decorate_message adds bold escape sequences to message, and the class
name of exception (like " (RuntimeError)) of "message (RuntimeError)").
2022-02-22 11:55:40 +09:00
Yusuke Endoh f207f7a193 Do not escape error message
[Feature #18367]
2022-02-22 11:55:40 +09:00
Yusuke Endoh 36e31b09cd error.c: Refactoring
Factor out from rb_error_write the responsibility to check if stderr is
a tty.
2022-02-22 11:55:40 +09:00
OKURA Masafumi 8d5292f702 Trim extra whitespace in inaccesible error message
One whitespace is already included in `inaccessible_mesg_for` macro.
This extra whitespace is included since 72ff61f4a8
2021-09-01 13:18:55 +09:00
Nobuyoshi Nakada f6a080047e
Limit bactrace length from Exception#full_message 2020-12-27 20:50:15 +09:00
Yusuke Endoh eee93bc933 eval_error.c: fix off-by-one error for --backtrace-limit
https://bugs.ruby-lang.org/issues/17413
2020-12-21 11:40:48 +09:00
Nobuyoshi Nakada 579645d9f8
Fixed infinite loop at error in printing cause [Bug #17033] 2020-07-15 21:39:20 +09:00
Yusuke Endoh 39365b46e2
Merge pull request #3047 from mame/suppress-backtrace
Add `--suppress-backtrace=num` option to limit the backtrace length
2020-05-15 01:22:56 +09:00
Nobuyoshi Nakada 3ef09c6e66
eval_error.c: default nil as "reverse" is now false [Feature #8661] 2020-04-21 19:29:16 +09:00
Yusuke Endoh 487d0c99d5 eval_error.c: revert the "reversed" backtrace [Feature #8661]
Now, the order is good, old-fashioned style:

```
$ ./local/bin/ruby -e 'def foo; raise; end
def bar; foo; end
def baz; bar; end
def qux; baz; end
qux
'
-e:1:in `foo': unhandled exception
	from -e:2:in `bar'
	from -e:3:in `baz'
	from -e:4:in `qux'
	from -e:5:in `<main>'
```
2020-04-21 17:39:32 +09:00
Nobuyoshi Nakada 155f64e3c4
Raise EPIPE at broken pipe for the backward compatibility
Instead of SignalException for SIGPIPE, raise `Errno::EPIPE` with
instance variable `signo` and re-send that signal at exit.
[Feature #14413]
2020-04-15 21:05:39 +09:00
Nobuyoshi Nakada 0c2d81dada
Renamed ruby_finalize_{0,1}
And pass rb_execution_context_t as an argument.
2019-08-13 09:47:08 +09:00
Nobuyoshi Nakada 0c6c937904
Removed duplicate highlighting 2019-07-15 19:39:47 +09:00
git 5a42dca688 * expand tabs. 2019-07-15 16:51:18 +09:00
Nobuyoshi Nakada 5e0d27a32f
Removed dead code
If `emesg` is `Qundef`, it is not a message string and then `elen`
(the length of the message) is 0.  So `emesg` cannot be `Qundef` in
the `elen != 0` block.  Pointed out by Coverity Scan.
2019-07-15 16:49:39 +09:00
nobu c6fb7c1f33 eval_error.c: should not escapce newline and tab
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66917 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-24 10:10:18 +00:00
svn 497075b3a1 * expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-08 09:08:37 +00:00
nobu 50784a0a44 Defer escaping control char in error messages
* eval_error.c (print_errinfo): defer escaping control char in
  error messages until writing to stderr, instead of quoting at
  building the message.  [ruby-core:90853] [Bug #15497]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-08 09:08:31 +00:00
nobu 1849288722 Fix for circular causes
* eval_error.c (show_cause): get rid of infinite recursion on
  circular causes.  [Bug #15447]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22 07:14:14 +00:00
mame 010a742cb6 eval_error.c (show_cause): check if cause is an Exception or not
Fixes [Bug #15447]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-21 11:44:21 +00:00
shyouhei 06e2873ed1 eval_error.c: log10(0) is ERANGE
By definition, the logarithm of 0 is negative infinity.  This is a
pole error (cf: cf: ISO/IEC 9899:1999 section 7.12.1 paragraph 3) and
of course, cannot fit into an `int` value.  We have to resort to
INT_MIN.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15 09:03:03 +00:00
naruse 7594a8df75 fix error message and backtrace order
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-27 23:13:34 +00:00
naruse 48af6fd544 Print exception's cause like Java
Print `cause` of the exception if the exception is not caught and printed
its backtraces and error message [Feature #8257]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-27 21:45:30 +00:00
normal 62c3610583 rb_execution_context_t: pack bits, 256 -> 252 bytes (on 32-bit)
Maybe execution contexts will become more common.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-19 20:56:10 +00:00
nobu fa8b08b424 Prefer `rb_fstring_lit` over `rb_fstring_cstr`
The former states explicitly that the argument must be a literal,
and can optimize away `strlen` on all compilers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13 09:59:22 +00:00
nobu aa2b32ae4b eval_error.c: fix loop on exception in message
* error.c (rb_get_message): accessor to the message.

* eval_error.c (rb_ec_error_print): handle exceptions on fetching
  the message.  [Bug #14566]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-11 08:03:43 +00:00
nobu 1032f093cc eval_error.c: reset attributes
* eval_error.c (print_errinfo): reset all attributes for each
  lines before newlines.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 03:48:56 +00:00
nobu b07e4af869 eval_error.c: last newline
* eval_error.c (print_errinfo): do not print an empty line at the
  end when the message ends with a newline.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13 03:40:10 +00:00
nobu 2851b2c55f eval_error.c: fix underflow
* eval_error.c (print_errinfo): get rid of negative string length.
  [ruby-core:86086] [Bug #14598]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-12 13:04:28 +00:00
nobu daad618740 eval_error.c: rb_error_write flags
* eval_error.c (rb_error_write): add highlight and reverse mode
  flags.  defaulted to rb_stderr_tty_p() if Qnil.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-23 08:39:03 +00:00
nobu 89f0419575 eval_error.c: reset in each line
* eval_error.c (print_errinfo): reset in each line, so that
  Exception#full_message ends with a newline and puts will not
  print an extra newline.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 05:38:37 +00:00
nobu ac4d348d45 eval_error.c: concat directly
* eval_error.c (write_warn, write_warn2): get rid of unnecessary
  intermediate string objects, concat directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 04:57:04 +00:00
nobu 23a0a9b90d eval_error.c: renamed an argument
* eval_error.c (print_errinfo): renamed argument `colored` as
  `highlight`, as it does not use colors.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 04:16:31 +00:00
shyouhei 13af45c0d6 fix uninitialized variable
Likewise this can easily be noticed if you read the warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-02 06:42:03 +00:00
ngoto d088cb2727 eval_error.c: Fix compile error on Solaris 10
* eval_error.c (write_warn, write_warn2, write_warn_str): Fix compile
  error "operands have incompatible types" with Oracle Solaris Studio
  12.4 on Solaris 10.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-18 15:46:56 +00:00
sorah d18fb887ea error.c(rb_error_write): Remove ec_ from its name
It's unrelated to rb_execution_context_t during writing the patch
r61154

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 12:17:38 +00:00
sorah 2ce0847e9e hotfix implicit-function-declaration
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 12:10:21 +00:00
sorah 0d7718896c error.c(exc_full_message): Exception#full_message
Add a method to retrieve a String expression of an exception,
formatted in the same way that Ruby prints an uncaught exception out.

[Feature #14141]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 11:47:16 +00:00
sorah b5e0ca4730 Log exception with bold and underline for TTYs
Print error message in bold/underlined text if STDERR is unchanged and a tty.
[Feature #14160] [experimental]

Screenshot: https://img.sorah.jp/s/2017-11-29_1711_xj2fu.png

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-29 11:14:23 +00:00
ko1 7a666c6766 rb_source_location() may return nil.
* vm.c (rb_source_location): return nil if path is not found.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 05:35:58 +00:00
ko1 48ce4cb414 * eval_intern.h: rename macros rb_thread_raised_* to
rb_ec_raised_*.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 05:22:09 +00:00
ko1 ee189904f0 rename to rb_ec_set_raised().
* thread.c (rb_threadptr_set_raised): rename to rb_ec_set_raised
  and accepts `ec`


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 05:12:39 +00:00