From c28444893ab14bd35381c7b60545fd248cc7d877 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Fri, 2 Jul 2021 23:52:13 +0200 Subject: [PATCH 1/3] Fix test-smob-mark * test-suite/standalone/test-smob-mark.c (init_smob_type): Correct size of smob type. (free_x): Clear smob data instead of local variable. (test_scm_smob_mark): Put smobs in array to ensure marking. --- test-suite/standalone/test-smob-mark.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test-suite/standalone/test-smob-mark.c b/test-suite/standalone/test-smob-mark.c index d0bb5336a..ee7e02029 100644 --- a/test-suite/standalone/test-smob-mark.c +++ b/test-suite/standalone/test-smob-mark.c @@ -79,7 +79,7 @@ free_x (SCM x) x_t *c_x; c_x = (x_t *) SCM_SMOB_DATA (x); scm_gc_free (c_x, sizeof (x_t), "x"); - c_x = NULL; + SCM_SET_SMOB_DATA (x, NULL); return 0; } @@ -100,14 +100,17 @@ print_x (SCM x, SCM port, scm_print_state * pstate SCM_UNUSED) static void test_scm_smob_mark () { + SCM *smobs = scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, "smobs"); + int i; mark_call_count = 0; for (i = 0; i < SMOBS_COUNT; i++) - make_x (); + smobs[i] = make_x (); scm_gc (); if (mark_call_count < SMOBS_COUNT) { - fprintf (stderr, "FAIL: SMOB mark function called for each SMOB\n"); + // Print pointer so it cannot be collected before. + fprintf (stderr, "FAIL: SMOB mark function called for each SMOB (smobs = %p)\n", smobs); exit (EXIT_FAILURE); } } @@ -115,7 +118,7 @@ test_scm_smob_mark () static void init_smob_type () { - x_tag = scm_make_smob_type ("x", sizeof (x_t)); + x_tag = scm_make_smob_type ("x", sizeof (x_t *)); scm_set_smob_free (x_tag, free_x); scm_set_smob_print (x_tag, print_x); scm_set_smob_mark (x_tag, mark_x); -- 2.32.0