Skip to content

test(session): clear any leftovers from previous tests#1528

Merged
jpnurmi merged 1 commit intomasterfrom
jpnurmi/test/session
Feb 18, 2026
Merged

test(session): clear any leftovers from previous tests#1528
jpnurmi merged 1 commit intomasterfrom
jpnurmi/test/session

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented Feb 18, 2026

When running session tests with a non-clean database, old envelopes get picked up during SDK init. The send_envelope callback in session_basics assumes every envelope contains exactly one session item, and crashes when it encounters an unexpected raw envelope:

Test session_basics...                          [ FAILED ]
  test_session.c:12: Check 0 == 1... failed

Program received signal SIGSEGV, Segmentation fault.
sentry__envelope_item_get_header (item=item@entry=0x0, key=key@entry=0x5555555d4d6e "type") at src/sentry_envelope.c:1047
1047        return sentry_value_get_by_key(item->headers, key);
(gdb) bt
#0  sentry__envelope_item_get_header (item=0x0, key=0x5555555d4d6e "type") at src/sentry_envelope.c:1047
#1  0x00005555555bbc84 in send_envelope (envelope=0x5555556324d0, data=0x7fffffffd388) at tests/unit/test_session.c:15
#2  0x00005555555848df in sentry__process_old_runs (options=0x5555556210d0, last_crash=0) at src/sentry_database.c:293
#3  0x000055555557f922 in sentry_init (options=0x5555556210d0) at src/sentry_core.c:288
#4  0x00005555555bc4ff in test_sentry_session_basics () at tests/unit/test_session.c:76
#5  0x00005555555a630e in test_do_run__ (test=test@entry=0x5555555fc440 <test_list__+2848>, index=index@entry=0) at include/../vendor/acutest.h:943
#6  0x000055555556f292 in test_run__ (test=0x5555555fc440 <test_list__+2848>, index=0, master_index=178) at include/../vendor/acutest.h:1114
#7  main (argc=<optimized out>, argv=<optimized out>) at include/../vendor/acutest.h:1623

This clears the database before SDK init in both session_basics and count_sampled_events, making the tests resilient to leftover state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jpnurmi jpnurmi merged commit 27364c7 into master Feb 18, 2026
45 checks passed
@jpnurmi jpnurmi deleted the jpnurmi/test/session branch February 18, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants