[#122369] [Ruby Bug#21392] Data classes do not allow overriding #inspect — "austin (Austin Ziegler) via ruby-core" <ruby-core@...>

Issue #21392 has been reported by austin (Austin Ziegler).

8 messages 2025/06/01

[#122411] [Ruby Bug#21396] Set#initialize should call Set#add on items passed in — "tenderlovemaking (Aaron Patterson) via ruby-core" <ruby-core@...>

Issue #21396 has been reported by tenderlovemaking (Aaron Patterson).

12 messages 2025/06/04

[#122506] [Ruby Feature#21435] Kernel#optional as a conditional #then — "Alexander.Senko (Alexander Senko) via ruby-core" <ruby-core@...>

SXNzdWUgIzIxNDM1IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IEFsZXhhbmRlci5TZW5rbyAoQWxleGFu

11 messages 2025/06/10

[#122557] [Ruby Bug#21445] [BUG] push_mark_stack() called for broken object raised since cd9f447be247478d2eb3da985295735cce20cb23 — "yahonda (Yasuo Honda) via ruby-core" <ruby-core@...>

Issue #21445 has been reported by yahonda (Yasuo Honda).

10 messages 2025/06/19

[#122615] [Ruby Misc#21458] Test 'make install'? — "MSP-Greg (Greg L) via ruby-core" <ruby-core@...>

Issue #21458 has been reported by MSP-Greg (Greg L).

11 messages 2025/06/28

[ruby-core:122588] [Ruby Bug#19473] can't be called from trap context (ThreadError) is too limiting

From: "ioquatix (Samuel Williams) via ruby-core" <ruby-core@...>
Date: 2025-06-24 04:21:05 UTC
List: ruby-core #122588
Issue #19473 has been updated by ioquatix (Samuel Williams).


Had to special case another mutex: https://github.com/ruby/ruby/pull/13684

----------------------------------------
Bug #19473: can't be called from trap context (ThreadError) is too limiting
https://bugs.ruby-lang.org/issues/19473#change-113823

* Author: Eregon (Benoit Daloze)
* Status: Open
* ruby -v: ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
Simple reproducer:
```
$ ruby -ve 'm=Mutex.new; trap(:HUP) { m.synchronize { p :OK } }; Process.kill :HUP, Process.pid; sleep 0.1'
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
-e:1:in `synchronize': can't be called from trap context (ThreadError)
	from -e:1:in `block in <main>'
	from -e:1:in `kill'
	from -e:1:in `<main>'
```

Expected behavior:
```
$ ruby -ve 'm=Mutex.new; trap(:HUP) { m.synchronize { p :OK } }; Process.kill :HUP, Process.pid; sleep 0.1'
truffleruby 22.3.1, like ruby 3.0.3, GraalVM CE Native [x86_64-linux]
:OK

$ ruby -ve 'm=Mutex.new; trap(:HUP) { m.synchronize { p :OK } }; Process.kill :HUP, Process.pid; sleep 0.1'
jruby 9.4.0.0 (3.1.0) 2022-11-23 95c0ec159f OpenJDK 64-Bit Server VM 17.0.6+10 on 17.0.6+10 +jit [x86_64-linux]
:OK
```

This exception is highly problematic, for instance it breaks `Timeout.timeout` in `trap`:
https://github.com/ruby/timeout/issues/17#issuecomment-1142035939

I suppose this behavior is because *sometimes* it's problematic to lock a Mutex in trap, e.g., if it's already locked by the main thread/fiber.
But that would otherwise already raise `deadlock; recursive locking (ThreadError)`, so there is no point to fail early.
And that's just one case, not all, so we should not always raise an exception.

There seems to be no valid reason to prevent *all* `Mutex#synchronize` in `trap`.
After all, if the Mutex for instance is only used in `trap`, it's well-defined AFAIK.
For instance a given trap handler does not seem executed concurrently:
```
$ ruby -ve 'trap(:HUP) { puts "in trap\n"+caller.join("\n")+"\n\n"; sleep 0.1 }; pid = Process.pid; Process.wait fork { 20.times { Process.kill :HUP, pid } }; sleep 1'
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
in trap
-e:1:in `wait'
-e:1:in `<main>'

in trap
-e:1:in `wait'
-e:1:in `<main>'

in trap
-e:1:in `wait'
-e:1:in `<main>'

in trap
-e:1:in `wait'
-e:1:in `<main>'

in trap
-e:1:in `wait'
-e:1:in `<main>'

in trap
-e:1:in `wait'
-e:1:in `<main>'

```

And if the trap handler using the Mutex is never called while the Mutex is held by the main thread/fiber, there is also no problem.



-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- [email protected]
 To unsubscribe send an email to [email protected]
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/


In This Thread