Skip to content

core: fix segmentation fault during global teardown (#3288)#3331

Open
harshal24-chavan wants to merge 1 commit into
Haivision:masterfrom
harshal24-chavan:master
Open

core: fix segmentation fault during global teardown (#3288)#3331
harshal24-chavan wants to merge 1 commit into
Haivision:masterfrom
harshal24-chavan:master

Conversation

@harshal24-chavan

Copy link
Copy Markdown

Removed the HLOGC macros from closeAllSockets() that were causing a segmentation fault during global teardown due to static destruction order. Added a warning comment to prevent future logging in this function.

Fixes #3288

@ethouris

ethouris commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

I had a different solution in mind.

What I need is to have some flag that is 0 by default, but it enables logs in this area. Let's say:

#define SRT_ENABLE_UNSAFE_LOGS 0

#if SRT_ENABLE_UNSAFE_LOGS
#define HLOGC_UNSAFE HLOGC
#else
#define HLOGC_UNSAFE(...) (void)0
#endif

Now, all HLOGC macro uses in this function should be replaced by HLOGC_UNSAFE. In the default configuration this will be simply turned into no instruction. But a developer may need to enable logs in this area temporarily to track any problems, and to do that, they can change SRT_ENABLE_UNSAFE_LOGS locally.

@ethouris ethouris added Type: Maintenance Work required to maintain or clean up the code [core] Area: Changes in SRT library core labels Jun 9, 2026
@harshal24-chavan

Copy link
Copy Markdown
Author

okay! yes makes sense, keep it for debugging & exclude them for normal use, thanks for correcting. I'll implement that.

Fixes Haivision#3288. Removed HLOGC macros from closeAllSockets() as they were being triggered during the static destruction phase, attempting to access already deleted global logging objects.
@harshal24-chavan

Copy link
Copy Markdown
Author

Following the pattern I saw in the dev branch with the DONT_HLOGC configuration, I placed the new #define block directly below the #include statements at the top of the file for better discoverability and consistency.

@ethouris

Copy link
Copy Markdown
Collaborator

Yes, that's very good. In perspective also the dev branch will be updated with that solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The functions called from destructor of CUDTUnited shall not refer to any global objects

2 participants