[ruby-core:113908] [Ruby master Bug#19732] Possible missing header (stdint.h) in event.h

Issue #19732 has been reported by itarato (Peter Arato). ---------------------------------------- Bug #19732: Possible missing header (stdint.h) in event.h https://bugs.ruby-lang.org/issues/19732 * Author: itarato (Peter Arato) * Status: Open * Priority: Normal * ruby -v: HEAD * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Ruby's event.h (https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i...) is using type aliases from stdint.h, however it's not directly included. An example where this causes issues is when using `rb_debug_inspector_current_depth()` https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i.... In a gem using a C-extension that already includes `debug.h`, when adding the call `rb_debug_inspector_current_depth()`, the compilation fails with: ``` shell make compiling debug_inspector.c In file included from /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/debug.h:16, from debug_inspector.c:12: /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/internal/event.h:105:9: error: unknown type name ‘uint32_t’ 105 | typedef uint32_t rb_event_flag_t; | ^~~~~~~~ ``` This is on `ruby/ruby` latest commit (813a5f4fc46a24ca1695d23c159250b9e1080ac7), but also tried on tag 3.2 (same error). I've also proposed a fix: https://github.com/ruby/ruby/pull/7945 -- https://bugs.ruby-lang.org/

Issue #19732 has been updated by nobu (Nobuyoshi Nakada). Status changed from Open to Feedback Could you share the code to reproduce? Is it https://github.com/banister/debug_inspector/tree/master/ext/debug_inspector/... ---------------------------------------- Bug #19732: Possible missing header (stdint.h) in event.h https://bugs.ruby-lang.org/issues/19732#change-103565 * Author: itarato (Peter Arato) * Status: Feedback * Priority: Normal * ruby -v: HEAD * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Ruby's event.h (https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i...) is using type aliases from stdint.h, however it's not directly included. An example where this causes issues is when using `rb_debug_inspector_current_depth()` https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i.... In a gem using a C-extension that already includes `debug.h`, when adding the call `rb_debug_inspector_current_depth()`, the compilation fails with: ``` shell make compiling debug_inspector.c In file included from /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/debug.h:16, from debug_inspector.c:12: /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/internal/event.h:105:9: error: unknown type name ‘uint32_t’ 105 | typedef uint32_t rb_event_flag_t; | ^~~~~~~~ ``` This is on `ruby/ruby` latest commit (813a5f4fc46a24ca1695d23c159250b9e1080ac7), but also tried on tag 3.2 (same error). I've also proposed a fix: https://github.com/ruby/ruby/pull/7945 -- https://bugs.ruby-lang.org/

Issue #19732 has been updated by itarato (Peter Arato). While preparing that diff I realized what happened. I'm using `clang-format` which sorts includes and ordered https://github.com/banister/debug_inspector/blob/5424c4094df30adfecd961a4e77... to: ```c #include "ruby/debug.h" #include "ruby/ruby.h" ``` in which case `ruby.h` do not have the chance to trigger the include of `stdint.h` in time. Would this count as an issue? My guess is that clang-format is pretty popular (eg default formatter in vscode) so changes are more folks would bump to this when writing new C extensions. ---------------------------------------- Bug #19732: Possible missing header (stdint.h) in event.h https://bugs.ruby-lang.org/issues/19732#change-103570 * Author: itarato (Peter Arato) * Status: Feedback * Priority: Normal * ruby -v: HEAD * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Ruby's event.h (https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i...) is using type aliases from stdint.h, however it's not directly included. An example where this causes issues is when using `rb_debug_inspector_current_depth()` https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i.... In a gem using a C-extension that already includes `debug.h`, when adding the call `rb_debug_inspector_current_depth()`, the compilation fails with: ``` shell make compiling debug_inspector.c In file included from /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/debug.h:16, from debug_inspector.c:12: /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/internal/event.h:105:9: error: unknown type name ‘uint32_t’ 105 | typedef uint32_t rb_event_flag_t; | ^~~~~~~~ ``` This is on `ruby/ruby` latest commit (813a5f4fc46a24ca1695d23c159250b9e1080ac7), but also tried on tag 3.2 (same error). I've also proposed a fix: https://github.com/ruby/ruby/pull/7945 -- https://bugs.ruby-lang.org/

Issue #19732 has been updated by nobu (Nobuyoshi Nakada). Status changed from Feedback to Open Although I don't think it is a big issue as we don't assume or guarantee all our headers can be usable individually, welcome the improvement. It seems ruby/internal/event.h is which really needs `uint32_t`. ```shell-session $ clang -I/opt/local/include/ruby-3.3.0+0/{x86_64-darwin22/,} -include ruby/internal/event.h -c -o /dev/null -xc - < /dev/null In file included from <built-in>:1: /opt/local/include/ruby-3.3.0+0/ruby/internal/event.h:103:9: error: unknown type name 'uint32_t' typedef uint32_t rb_event_flag_t; ^ 1 error generated. ``` Also `HAVE_STDINT_H` is usable there. ```shell-session $ clang -I/opt/local/include/ruby-3.3.0+0/{x86_64-darwin22/,} -include ruby/internal/event.h -E -dM -xc - < /dev/null | grep HAVE_STDINT_H #define HAVE_STDINT_H 1 ``` So it would be nice to add the `include` with checking `HAVE_STDINT_H` in event.h file. ```diff diff --git a/include/ruby/internal/event.h b/include/ruby/internal/event.h index 04b137a1939..bbf0aa45019 100644 --- a/include/ruby/internal/event.h +++ b/include/ruby/internal/event.h @@ -23,6 +23,10 @@ #include "ruby/internal/dllexport.h" #include "ruby/internal/value.h" +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif + /* These macros are not enums because they are wider than int.*/ /** ``` ---------------------------------------- Bug #19732: Possible missing header (stdint.h) in event.h https://bugs.ruby-lang.org/issues/19732#change-103572 * Author: itarato (Peter Arato) * Status: Open * Priority: Normal * ruby -v: HEAD * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Ruby's event.h (https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i...) is using type aliases from stdint.h, however it's not directly included. An example where this causes issues is when using `rb_debug_inspector_current_depth()` https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i.... In a gem using a C-extension that already includes `debug.h`, when adding the call `rb_debug_inspector_current_depth()`, the compilation fails with: ``` shell make compiling debug_inspector.c In file included from /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/debug.h:16, from debug_inspector.c:12: /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/internal/event.h:105:9: error: unknown type name ‘uint32_t’ 105 | typedef uint32_t rb_event_flag_t; | ^~~~~~~~ ``` This is on `ruby/ruby` latest commit (813a5f4fc46a24ca1695d23c159250b9e1080ac7), but also tried on tag 3.2 (same error). I've also proposed a fix: https://github.com/ruby/ruby/pull/7945 -- https://bugs.ruby-lang.org/

Issue #19732 has been updated by nobu (Nobuyoshi Nakada). Sorry, I got wrongly if it were about to add it to debug.h. The file is correct, but just the `include` should be after the other `include`s with `HAVE_STDINT_H` check. ---------------------------------------- Bug #19732: Possible missing header (stdint.h) in event.h https://bugs.ruby-lang.org/issues/19732#change-103573 * Author: itarato (Peter Arato) * Status: Open * Priority: Normal * ruby -v: HEAD * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Ruby's event.h (https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i...) is using type aliases from stdint.h, however it's not directly included. An example where this causes issues is when using `rb_debug_inspector_current_depth()` https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i.... In a gem using a C-extension that already includes `debug.h`, when adding the call `rb_debug_inspector_current_depth()`, the compilation fails with: ``` shell make compiling debug_inspector.c In file included from /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/debug.h:16, from debug_inspector.c:12: /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/internal/event.h:105:9: error: unknown type name ‘uint32_t’ 105 | typedef uint32_t rb_event_flag_t; | ^~~~~~~~ ``` This is on `ruby/ruby` latest commit (813a5f4fc46a24ca1695d23c159250b9e1080ac7), but also tried on tag 3.2 (same error). I've also proposed a fix: https://github.com/ruby/ruby/pull/7945 -- https://bugs.ruby-lang.org/

Issue #19732 has been updated by itarato (Peter Arato). Thanks for pointing that out. Updated the PR (https://github.com/ruby/ruby/pull/7945) with those adjustments. ---------------------------------------- Bug #19732: Possible missing header (stdint.h) in event.h https://bugs.ruby-lang.org/issues/19732#change-103574 * Author: itarato (Peter Arato) * Status: Open * Priority: Normal * ruby -v: HEAD * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Ruby's event.h (https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i...) is using type aliases from stdint.h, however it's not directly included. An example where this causes issues is when using `rb_debug_inspector_current_depth()` https://github.com/ruby/ruby/blob/813a5f4fc46a24ca1695d23c159250b9e1080ac7/i.... In a gem using a C-extension that already includes `debug.h`, when adding the call `rb_debug_inspector_current_depth()`, the compilation fails with: ``` shell make compiling debug_inspector.c In file included from /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/debug.h:16, from debug_inspector.c:12: /home/itarato/.rubies/ruby-master/include/ruby-3.3.0+0/ruby/internal/event.h:105:9: error: unknown type name ‘uint32_t’ 105 | typedef uint32_t rb_event_flag_t; | ^~~~~~~~ ``` This is on `ruby/ruby` latest commit (813a5f4fc46a24ca1695d23c159250b9e1080ac7), but also tried on tag 3.2 (same error). I've also proposed a fix: https://github.com/ruby/ruby/pull/7945 -- https://bugs.ruby-lang.org/
participants (2)
-
itarato (Peter Arato)
-
nobu (Nobuyoshi Nakada)