Skip to content

Commit

Permalink
[#963] [V70005] Fix assert failure in MUPIP INTEG (jnl_file_close_tim…
Browse files Browse the repository at this point in the history
…er call in ss_initiate)

Background
----------
* When run with a Debug build of YottaDB, a `mupip integ` failed as follows.

  ```c
  %YDB-F-ASSERT, Assert failed in sr_unix/gt_timers.c line 504 for expression ((INTRPT_OK_TO_INTERRUPT == intrpt_ok_state) || (INTRPT_IN_DB_CSH_GETN == intrpt_ok_state) || (INTRPT_IN_GDS_RUNDOWN == intrpt_ok_state))
  ```

Issue
-----
* The issue is that GT.M V7.0-005 added a `START_JNL_FILE_CLOSE_TIMER_IF_NEEDED` call to
  the `SET_SNAPSHOTS_IN_PROG` macro as can be seen in the below diff.

  ```diff
  $ git show -U0 tags/V7.0-005 sr_port/gdsfhead.h
  @@ -4187 +4187 @@ MBSTART {
  -#define SET_SNAPSHOTS_IN_PROG(X)	((X)->snapshot_in_prog = TRUE)
  +#define SET_SNAPSHOTS_IN_PROG(X)	MBSTART { (X)->snapshot_in_prog = TRUE; START_JNL_FILE_CLOSE_TIMER_IF_NEEDED; } MBEND
  ```

* This caused the assert failure in the following code (which is present only in YottaDB, not in GT.M).

  **sr_unix/gt_timers.c**
  ```c
    501         } else if (jnl_file_close_timer_fptr == handler)
    502         {       /* Account for known instances of the above function being called from within a deferred zone. */
    503                 assert((INTRPT_OK_TO_INTERRUPT == intrpt_ok_state) || (INTRPT_IN_DB_CSH_GETN == intrpt_ok_state)
    504                         || (INTRPT_IN_GDS_RUNDOWN == intrpt_ok_state));
    505                 safe_to_add = TRUE;
  ```

* Below are details from the gdb analysis of the core file

  ```c
  (gdb) where
  #0  __pthread_kill_implementation (no_tid=0, signo=3, threadid=140357926831936) at ./nptl/pthread_kill.c:44
  #1  __pthread_kill_internal (signo=3, threadid=140357926831936) at ./nptl/pthread_kill.c:78
  #2  __GI___pthread_kill (threadid=140357926831936, signo=3) at ./nptl/pthread_kill.c:89
  #3  gtm_dump_core () at sr_unix/gtm_dump_core.c:74
  #4  gtm_fork_n_core () at sr_unix/gtm_fork_n_core.c:163
  #5  ch_cond_core () at sr_unix/ch_cond_core.c:80
  #6  rts_error_va (csa=0x0, argcnt=7, var=0x7fff19e828f0) at sr_unix/rts_error.c:199
  #7  rts_error_csa (csa=0x0, argcnt=7) at sr_unix/rts_error.c:100
  #8  start_timer (tid=140357912091280, time_to_expir=60000000000, handler=0x7fa79f7dda90 <jnl_file_close_timer>, hdata_len=0, hdata=0x0) at sr_unix/gt_timers.c:503
  #9  ss_initiate (reg=0x55b37821b170, util_ss_ptr=0x55b37821a9c0, ss_ctx=0x55b378219110, preserve_snapshot=0, calling_utility=0x7fa7a03c8506 "MUPIP INTEG") at sr_unix/ss_initiate.c:666
  #10 mu_int_reg (reg=0x55b37821b170, return_value=0x7fff19e8560c, return_after_open=0) at sr_port/mu_int_reg.c:192
  #11 mupip_integ () at sr_port/mupip_integ.c:438
  #12 mupip_main (argc=4, argv=0x7fff19e89608, envp=0x7fff19e89630) at sr_unix/mupip_main.c:130
  #13 dlopen_libyottadb (argc=4, argv=0x7fff19e89608, envp=0x7fff19e89630, main_func=0x55b37723f004 "mupip_main") at sr_unix/dlopen_libyottadb.c:151
  #14 main (argc=4, argv=0x7fff19e89608, envp=0x7fff19e89630) at sr_unix/mupip.c:21

  (gdb) f 8
  #8  start_timer (tid=140357912091280, time_to_expir=60000000000, handler=0x7fa79f7dda90 <jnl_file_close_timer>, hdata_len=0, hdata=0x0) at sr_unix/gt_timers.c:503
  503                     assert((INTRPT_OK_TO_INTERRUPT == intrpt_ok_state) || (INTRPT_IN_DB_CSH_GETN == intrpt_ok_state)

  (gdb) p intrpt_ok_state
  $1 = INTRPT_IN_SS_INITIATE
  ```

Fix
---
* Now that we know this is expected, the above value is also added as an accepted value in the assert.
  • Loading branch information
nars1 committed Apr 11, 2024
1 parent 1b80e81 commit 7af2c3a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sr_unix/gt_timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void start_timer(TID tid, uint8 time_to_expir, void (*handler)(), int4 hdata_len
} else if (jnl_file_close_timer_fptr == handler)
{ /* Account for known instances of the above function being called from within a deferred zone. */
assert((INTRPT_OK_TO_INTERRUPT == intrpt_ok_state) || (INTRPT_IN_DB_CSH_GETN == intrpt_ok_state)
|| (INTRPT_IN_GDS_RUNDOWN == intrpt_ok_state));
|| (INTRPT_IN_GDS_RUNDOWN == intrpt_ok_state) || (INTRPT_IN_SS_INITIATE == intrpt_ok_state));
safe_to_add = TRUE;
} else
{
Expand Down

0 comments on commit 7af2c3a

Please sign in to comment.