Skip to content

Commit 943943e

Browse files
committed
Add diagnostic fprintf for CI shutdown crash investigation
1 parent 0399044 commit 943943e

File tree

16 files changed

+319
-10
lines changed

16 files changed

+319
-10
lines changed

src/api/InkAPI.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ TSReturnCode sdk_sanity_check_mbuffer(TSMBuffer bufp);
155155
namespace
156156
{
157157

158+
// Track when InkAPI.cc static objects are destroyed.
159+
struct InkAPIDestructionTracker {
160+
~InkAPIDestructionTracker()
161+
{
162+
fprintf(stderr, "DEBUG: InkAPIDestructionTracker destroyed (InkAPI.cc statics)\n");
163+
fflush(stderr);
164+
}
165+
};
166+
static InkAPIDestructionTracker inkapi_destruction_tracker;
167+
158168
DbgCtl dbg_ctl_plugin{"plugin"};
159169
DbgCtl dbg_ctl_parent_select{"parent_select"};
160170
DbgCtl dbg_ctl_iocore_net{"iocore_net"};
@@ -166,6 +176,23 @@ DbgCtl dbg_ctl_rpc_api{"rpc.api"};
166176

167177
} // end anonymous namespace
168178

179+
// Use destructor attribute to run at the very end of static destruction.
180+
// Priority 65535 is the lowest (runs last).
181+
__attribute__((destructor(65535))) static void
182+
inkapi_very_late_destructor()
183+
{
184+
fprintf(stderr, "DEBUG: inkapi_very_late_destructor() running (priority 65535)\n");
185+
fflush(stderr);
186+
}
187+
188+
// Priority 101 runs relatively early in destructor order.
189+
__attribute__((destructor(101))) static void
190+
inkapi_early_destructor()
191+
{
192+
fprintf(stderr, "DEBUG: inkapi_early_destructor() running (priority 101)\n");
193+
fflush(stderr);
194+
}
195+
169196
/******************************************************/
170197
/* Allocators for field handles and standalone fields */
171198
/******************************************************/

src/iocore/eventsystem/UnixEThread.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ EThread::EThread(ThreadType att, Event *e) : tt(att), start_event(e)
128128
// threads won't have to deal with EThread memory deallocation.
129129
EThread::~EThread()
130130
{
131+
fprintf(stderr, "DEBUG: ~EThread() enter, this=%p, mutex=%p\n", (void *)this, (void *)mutex.get());
132+
fflush(stderr);
131133
ink_release_assert(mutex->thread_holding == this);
132134
if (this_ethread_ptr == this) {
133135
this_ethread_ptr = nullptr;
134136
}
135137

136138
mutex->nthread_holding -= THREAD_MUTEX_THREAD_HOLDING;
137139
MUTEX_UNTAKE_LOCK(mutex, this);
140+
fprintf(stderr, "DEBUG: ~EThread() exit\n");
141+
fflush(stderr);
138142
}
139143

140144
bool
@@ -359,6 +363,9 @@ EThread::execute_regular()
359363
void
360364
EThread::execute()
361365
{
366+
fprintf(stderr, "DEBUG: EThread::execute() starting, thread=%lu tt=%d\n", (unsigned long)pthread_self(), (int)tt);
367+
fflush(stderr);
368+
362369
// Do the start event first.
363370
// coverity[lock]
364371
if (start_event) {

src/iocore/eventsystem/UnixEventProcessor.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242
namespace
4343
{
4444

45+
// Track when UnixEventProcessor.cc static objects are destroyed.
46+
struct EventProcessorDestructionTracker {
47+
~EventProcessorDestructionTracker()
48+
{
49+
fprintf(stderr, "DEBUG: EventProcessorDestructionTracker destroyed (UnixEventProcessor.cc statics)\n");
50+
fflush(stderr);
51+
}
52+
};
53+
static EventProcessorDestructionTracker event_processor_destruction_tracker;
54+
4555
DbgCtl dbg_ctl_iocore_thread{"iocore_thread"};
4656
DbgCtl dbg_ctl_iocore_thread_start{"iocore_thread_start"};
4757

src/iocore/eventsystem/Watchdog.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ Monitor::Monitor(EThread *threads[], size_t n_threads, std::chrono::milliseconds
5050

5151
Monitor::~Monitor()
5252
{
53+
fprintf(stderr, "DEBUG: ~Monitor() enter - signaling shutdown\n");
54+
fflush(stderr);
5355
_shutdown.store(true, std::memory_order_release);
56+
fprintf(stderr, "DEBUG: ~Monitor() waiting for watchdog thread to join\n");
57+
fflush(stderr);
5458
_watchdog_thread.join();
59+
fprintf(stderr, "DEBUG: ~Monitor() watchdog thread joined, exiting destructor\n");
60+
fflush(stderr);
5561
}
5662

5763
void
@@ -104,6 +110,10 @@ Monitor::monitor_loop() const
104110

105111
std::this_thread::sleep_for(sleep_time);
106112
}
113+
fprintf(stderr, "DEBUG: monitor_loop() shutdown detected, about to call Dbg()\n");
114+
fflush(stderr);
107115
Dbg(dbg_ctl_watchdog, "Stopping watchdog");
116+
fprintf(stderr, "DEBUG: monitor_loop() Dbg() returned, exiting loop\n");
117+
fflush(stderr);
108118
}
109119
} // namespace Watchdog

src/iocore/net/SSLConfig.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ namespace
8686
{
8787
std::unique_ptr<ConfigUpdateHandler<SSLTicketKeyConfig>> sslTicketKey;
8888

89+
// Track when SSLConfig.cc static objects are destroyed.
90+
struct SSLConfigDestructionTracker {
91+
~SSLConfigDestructionTracker()
92+
{
93+
fprintf(stderr, "DEBUG: SSLConfigDestructionTracker destroyed (SSLConfig.cc statics)\n");
94+
fflush(stderr);
95+
}
96+
};
97+
static SSLConfigDestructionTracker sslconfig_destruction_tracker;
98+
8999
DbgCtl dbg_ctl_ssl_load{"ssl_load"};
90100
DbgCtl dbg_ctl_ssl_config_updateCTX{"ssl_config_updateCTX"};
91101
DbgCtl dbg_ctl_ssl_client_ctx{"ssl_client_ctx"};

src/iocore/net/SSLNetVConnection.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ ClassAllocator<SSLNetVConnection, false> sslNetVCAllocator("sslNetVCAllocator");
7878

7979
namespace
8080
{
81+
// Track when SSLNetVConnection.cc static objects are destroyed.
82+
struct SSLNetVCDestructionTracker {
83+
~SSLNetVCDestructionTracker()
84+
{
85+
fprintf(stderr, "DEBUG: SSLNetVCDestructionTracker destroyed (SSLNetVConnection.cc statics)\n");
86+
fflush(stderr);
87+
}
88+
};
89+
static SSLNetVCDestructionTracker sslnetvc_destruction_tracker;
90+
8191
DbgCtl dbg_ctl_ssl_early_data{"ssl_early_data"};
8292
DbgCtl dbg_ctl_ssl_early_data_show_received{"ssl_early_data_show_received"};
8393
DbgCtl dbg_ctl_ssl{"ssl"};

src/iocore/net/SSLUtils.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ asn1_strdup(ASN1_STRING *s)
10251025
static void
10261026
ssl_callback_info(const SSL *ssl, int where, int ret)
10271027
{
1028+
fprintf(stderr, "DEBUG: ssl_callback_info() called, ssl=%p, where=%d, ret=%d\n", (void *)ssl, where, ret);
1029+
fflush(stderr);
10281030
Dbg(dbg_ctl_ssl_load, "ssl_callback_info ssl: %p, where: %d, ret: %d, State: %s", ssl, where, ret, SSL_state_string_long(ssl));
10291031

10301032
SSLNetVConnection *netvc = SSLNetVCAccess(ssl);

src/proxy/http/HttpSM.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ using lbw = swoc::LocalBufferWriter<256>;
134134

135135
namespace
136136
{
137+
// Track when HttpSM.cc static objects are destroyed.
138+
struct HttpSMDestructionTracker {
139+
~HttpSMDestructionTracker()
140+
{
141+
fprintf(stderr, "DEBUG: HttpSMDestructionTracker destroyed (HttpSM.cc statics)\n");
142+
fflush(stderr);
143+
}
144+
};
145+
static HttpSMDestructionTracker httpsm_destruction_tracker;
146+
137147
DbgCtl dbg_ctl_proxyprotocol{"proxyprotocol"};
138148

139149
// Unique state machine identifier

src/proxy/logging/Log.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ LogConfig *Log::config = nullptr;
9090

9191
namespace
9292
{
93+
// Track when Log.cc static objects are destroyed.
94+
struct LogDestructionTracker {
95+
~LogDestructionTracker()
96+
{
97+
fprintf(stderr, "DEBUG: LogDestructionTracker destroyed (Log.cc statics)\n");
98+
fflush(stderr);
99+
}
100+
};
101+
static LogDestructionTracker log_destruction_tracker;
102+
93103
DbgCtl dbg_ctl_log_config{"log-config"};
94104
DbgCtl dbg_ctl_log_api_mutex{"log-api-mutex"};
95105
DbgCtl dbg_ctl_log_periodic{"log-periodic"};

src/records/RecHttp.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ SessionProtocolSet DEFAULT_QUIC_SESSION_PROTOCOL_SET;
9191
namespace
9292
{
9393

94+
// Track when RecHttp.cc static objects are destroyed.
95+
struct RecHttpDestructionTracker {
96+
~RecHttpDestructionTracker()
97+
{
98+
fprintf(stderr, "DEBUG: RecHttpDestructionTracker destroyed (RecHttp.cc statics)\n");
99+
fflush(stderr);
100+
}
101+
};
102+
static RecHttpDestructionTracker rechttp_destruction_tracker;
103+
94104
DbgCtl dbg_ctl_config{"config"};
95105
DbgCtl dbg_ctl_ssl_alpn{"ssl_alpn"};
96106

0 commit comments

Comments
 (0)