Bug 1901955

Summary: Segment fault when call log4c_init twice.
Product: [Fedora] Fedora EPEL Reporter: lexand <yamsjix>
Component: log4cAssignee: František Dvořák <valtri>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: epel7CC: steve.traylen, valtri, yamsjix
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: log4c-1.2.4-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-03-28 02:04:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description lexand 2020-11-26 13:29:46 UTC
Description of problem:
Segment fault when call log4c_init twice.

Version-Release number of selected component (if applicable):
1.2.4

How reproducible:


Steps to Reproduce:
1. call log4c_init
2. call log4c_fini
3. call log4c_init

Actual results:
Step 3 run sucessfully.

Expected results:
Segment fault & core dump

Additional info:
The code is below:
static sd_hash_t* log4c_layout_types(void)
{
    static sd_hash_t* types = NULL;

    if (!types)
	types = sd_hash_new(20, NULL);
    
    return types;
}

extern void log4c_layout_types_free( void ) {
	sd_hash_t * types = log4c_layout_types();
	if ( types != NULL ) {
		sd_hash_delete( types );
	}
}
"types" in function log4c_layout_types_free has delete, but the pointer need to be set to nullptr.
It need to change to code below:

static sd_hash_t* types = NULL;
static sd_hash_t* log4c_layout_types(void)
{
    if (!types)
	types = sd_hash_new(20, NULL);
    
    return types;
}

extern void log4c_layout_types_free( void ) {
    //sd_hash_t * types = log4c_layout_types();
    if ( types != NULL ) {
        sd_hash_delete( types );
    }
types = NULL;
}

The bug is existed in all packages, neither Fedora EPEL or EPEL for RHEL, in verison 1.2.4。

Comment 1 Steve Traylen 2021-03-08 10:09:55 UTC
Bug in rawhide also.

Comment 2 Fedora Update System 2021-03-13 18:40:53 UTC
FEDORA-EPEL-2021-0afde3da1b has been submitted as an update to Fedora EPEL 7. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2021-0afde3da1b

Comment 3 Fedora Update System 2021-03-13 21:51:49 UTC
FEDORA-EPEL-2021-0afde3da1b has been pushed to the Fedora EPEL 7 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2021-0afde3da1b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 lexand 2021-03-22 08:49:50 UTC
Conrect:
Expected results:
Step 3 run sucessfully.

Actual results:
Segment fault & core dump

And this BUG is also appeared in epel6 & epel8. They should be fixed anyway.

Comment 5 František Dvořák 2021-03-22 09:24:46 UTC
For EPEL7, the fix is in the testing repository.

Fedora branches and EPEL8 should be OK.

Comment 6 Fedora Update System 2021-03-28 02:04:38 UTC
FEDORA-EPEL-2021-0afde3da1b has been pushed to the Fedora EPEL 7 stable repository.
If problem still persists, please make note of it in this bug report.