lloda pushed a commit to branch main in repository guile. commit 9b00131539ca11a8112a4e88187e45bd40a6f7a7 Author: Rob Browning <r...@defaultvalue.org> AuthorDate: Tue Sep 9 12:15:54 2025 -0500
make-struct/no-tail scm_c_make_structv: ensure layout is symbol Previously we just tested for a layout via scm_is_true (SCM_LAYOUT ...), but layouts are symbols, and that test allowed us to proceed to the code in scm_is_valid_vtable_layout that called scm_i_symbol_chars on the "layout", segfaulting if the layout was say an integer, as it would be for something like this: (make-struct/no-tail (make-vtable standard-vtable-fields #f) 0) Since a layout must be a symbol, check via scm_is_symbol instead. * libguile/struct.c (scm_c_make_structv): test for layout via scm_is_symbol. Thanks to Ido Yariv for reporting the problem and Dale P. Smith for help determining the cause. Closes: 78789 --- NEWS | 4 ++++ libguile/struct.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 264c16322..d57c342a0 100644 --- a/NEWS +++ b/NEWS @@ -205,6 +205,10 @@ change. ** A numer of test incompatibilities with Darwin hosts have been fixed (<https://bugs.gnu.org/72547>) ** define guile-test as non-declarative because it uses load +** make-struct/no-tail and scm_c_make_structv no longer segfault + Previously they could if given the standard-vtable-fields, but inital + values that weren't compatible with a vtable. + (<https://bugs.gnu.org/78789>) Changes in 3.0.10 (since 3.0.9) diff --git a/libguile/struct.c b/libguile/struct.c index 68dcc0070..ef2225e6f 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -362,7 +362,7 @@ scm_c_make_structv (SCM vtable, size_t n_tail, size_t n_init, scm_t_bits *init) initialization, to humor GOOPS, so only validate if the layout was passed as an initarg. */ if (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_VTABLE) - && scm_is_true (SCM_VTABLE_LAYOUT (obj))) + && scm_is_symbol (SCM_VTABLE_LAYOUT (obj))) scm_i_struct_inherit_vtable_magic (vtable, obj); return obj;