[#108552] [Ruby master Bug#18782] Race conditions in autoload when loading the same feature with multiple threads. — "ioquatix (Samuel Williams)" <noreply@...>
Issue #18782 has been reported by ioquatix (Samuel Williams).
11 messages
2022/05/14
[ruby-core:108538] [Ruby master Bug#18777] NDEBUG macro defined after including ruby.h
From:
"Kerilk (Brice Videau)" <noreply@...>
Date:
2022-05-13 02:45:29 UTC
List:
ruby-core #108538
Issue #18777 has been updated by Kerilk (Brice Videau).
shyouhei (Shyouhei Urabe) wrote in #note-1:
> This is intentional. Devs hate assertions. See also https://bugs.ruby-lang.org/issues/16837 .
Thanks for confirming.
Here is the workaround I use should anybody with the same issue needs a solution.
```
// Ruby 3+ bleeds NDEBUG
// see https://bugs.ruby-lang.org/issues/18777#change-97580
#ifdef NDEBUG
#include <ruby.h>
#else
#include <ruby.h>
#undef NDEBUG
#endif
// DO NOT MOVE. If assert.h is included before ruby.h asserts will turn to no-op.
#include <assert.h>
```
----------------------------------------
Bug #18777: NDEBUG macro defined after including ruby.h
https://bugs.ruby-lang.org/issues/18777#change-97581
* Author: Kerilk (Brice Videau)
* Status: Closed
* Priority: Normal
* ruby -v: 3.0.2p107;3.1.2p20
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
Hello,
When using ruby 3+, including `ruby.h` results in the `NDEBUG` macro becoming defined, which deactivates assertions.
This simple (see attached `test.c` file) example illustrates this:
```C
#include <assert.h>
#include <ruby.h>
int main() {
assert(0);
return 0;
}
```
I expect:
```bash
gcc test.c
./a.out
```
To fail, and it does not. Commenting the `#include <ruby.h>` yields the expected result.
I found several discussion in the issues regarding `NDEBUG` in Ruby 3+, but none seem to describe this particular behavior. Sorry if I missed something.
Thanks.
---Files--------------------------------
test.c (79 Bytes)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>