Fix covscan defects, double-free error on java process end
This commit is contained in:
parent
0188d2b78c
commit
4d2984f1dc
3 changed files with 112 additions and 2 deletions
51
0001-Fix-a-pair-of-defects-uncovered-by-coverity.patch
Normal file
51
0001-Fix-a-pair-of-defects-uncovered-by-coverity.patch
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
From 54be469b8b91272e1f9852670a2f49e6bbecd0d8 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Filak <jfilak@redhat.com>
|
||||
Date: Wed, 22 Jan 2014 15:33:50 +0100
|
||||
Subject: [PATCH 1/2] Fix a pair of defects uncovered by coverity
|
||||
|
||||
---
|
||||
src/abrt-checker.c | 8 ++++++--
|
||||
src/jthread_map.c | 1 +
|
||||
2 files changed, 7 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/abrt-checker.c b/src/abrt-checker.c
|
||||
index 91485e0..713053c 100644
|
||||
--- a/src/abrt-checker.c
|
||||
+++ b/src/abrt-checker.c
|
||||
@@ -2886,7 +2886,11 @@ void parse_commandline_options(char *options)
|
||||
}
|
||||
else if (strcmp("executable", key) == 0)
|
||||
{
|
||||
- if (strcmp("threadclass", value) == 0)
|
||||
+ if (NULL == value || '\0' == value[0])
|
||||
+ {
|
||||
+ fprintf(stderr, "A value of '%s' option cannot be empty\n", key);
|
||||
+ }
|
||||
+ else if (strcmp("threadclass", value) == 0)
|
||||
{
|
||||
VERBOSE_PRINT("Use a thread class for 'executable'\n");
|
||||
executableFlags |= ABRT_EXECUTABLE_THREAD;
|
||||
@@ -2899,7 +2903,7 @@ void parse_commandline_options(char *options)
|
||||
}
|
||||
else
|
||||
{
|
||||
- fprintf(stderr, "Unknown 'executable' option's value '%s'\n", key);
|
||||
+ fprintf(stderr, "Unknown '%s' option's value '%s'\n", key, value);
|
||||
}
|
||||
}
|
||||
else
|
||||
diff --git a/src/jthread_map.c b/src/jthread_map.c
|
||||
index 4517398..4cb417b 100644
|
||||
--- a/src/jthread_map.c
|
||||
+++ b/src/jthread_map.c
|
||||
@@ -55,6 +55,7 @@ T_jthreadMap *jthread_map_new()
|
||||
if (NULL == map)
|
||||
{
|
||||
fprintf(stderr, __FILE__ ":" STRINGIZE(__LINE__) ": calloc() error\n");
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
pthread_mutex_init(&map->mutex, /*use default attributes*/NULL);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
From 71ac5da86488ace3ebb3f3fa4adc747a511634e2 Mon Sep 17 00:00:00 2001
|
||||
From: Pavel Tisnovsky <ptisnovs@dhcp-lab-190.englab.brq.redhat.com>
|
||||
Date: Mon, 3 Feb 2014 18:00:35 +0100
|
||||
Subject: [PATCH 2/2] Make sure that agent_onload and agent_onunload are
|
||||
processed only once.
|
||||
|
||||
---
|
||||
src/abrt-checker.c | 16 ++++++++++++++++
|
||||
1 file changed, 16 insertions(+)
|
||||
|
||||
diff --git a/src/abrt-checker.c b/src/abrt-checker.c
|
||||
index 713053c..f142d7e 100644
|
||||
--- a/src/abrt-checker.c
|
||||
+++ b/src/abrt-checker.c
|
||||
@@ -2923,10 +2923,17 @@ JNIEXPORT jint JNICALL Agent_OnLoad(
|
||||
char *options,
|
||||
void *reserved __UNUSED_VAR)
|
||||
{
|
||||
+ static int already_called = 0;
|
||||
jvmtiEnv *jvmti_env = NULL;
|
||||
jvmtiError error_code = JVMTI_ERROR_NONE;
|
||||
jint result;
|
||||
|
||||
+ /* we need to make sure the agent is initialized once */
|
||||
+ if (already_called) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ already_called = 1;
|
||||
pthread_mutex_init(&abrt_print_mutex, /*attr*/NULL);
|
||||
|
||||
INFO_PRINT("Agent_OnLoad\n");
|
||||
@@ -3001,6 +3008,15 @@ JNIEXPORT jint JNICALL Agent_OnLoad(
|
||||
*/
|
||||
JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm __UNUSED_VAR)
|
||||
{
|
||||
+ static int already_called = 0;
|
||||
+
|
||||
+ /* we need to make sure the agent is initialized once */
|
||||
+ if (already_called) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ already_called = 1;
|
||||
+
|
||||
pthread_mutex_destroy(&abrt_print_mutex);
|
||||
|
||||
INFO_PRINT("Agent_OnUnLoad\n");
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Name: abrt-java-connector
|
||||
Version: 1.0.8
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: JNI Agent library converting Java exceptions to ABRT problems
|
||||
|
||||
Group: System Environment/Libraries
|
||||
|
|
@ -11,6 +11,9 @@ License: GPLv2+
|
|||
URL: https://github.com/jfilak/abrt-java-connector
|
||||
Source0: https://github.com/jfilak/%{name}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
|
||||
|
||||
Patch0001: 0001-Fix-a-pair-of-defects-uncovered-by-coverity.patch
|
||||
Patch0002: 0002-Make-sure-that-agent_onload-and-agent_onunload-are-p.patch
|
||||
|
||||
BuildRequires: cmake
|
||||
BuildRequires: satyr-devel
|
||||
BuildRequires: libreport-devel
|
||||
|
|
@ -18,6 +21,7 @@ BuildRequires: abrt-devel
|
|||
BuildRequires: java-1.7.0-openjdk-devel
|
||||
BuildRequires: systemd-devel
|
||||
BuildRequires: gettext
|
||||
BuildRequires: git
|
||||
|
||||
Requires: abrt
|
||||
|
||||
|
|
@ -27,7 +31,7 @@ exceptions and transform them to ABRT problems
|
|||
|
||||
|
||||
%prep
|
||||
%setup -qn %{name}-%{commit}
|
||||
%autosetup -n %{name}-%{commit} -S git
|
||||
|
||||
|
||||
%build
|
||||
|
|
@ -67,6 +71,10 @@ make test
|
|||
|
||||
|
||||
%changelog
|
||||
* Tue Feb 04 2014 Jakub Filak <jfilak@redhat.com> - 1.0.8-2
|
||||
- Make sure that agent_onload and agent_onunload are processed only once
|
||||
- Fix a pair of defects uncovered by coverity
|
||||
|
||||
* Wed Jan 22 2014 Jakub Filak <jfilak@redhat.com> - 1.0.8-1
|
||||
- Do not report exceptions caught in a native method
|
||||
- Mark stack traces with 3rd party classes as not-reportable
|
||||
|
|
|
|||
Reference in a new issue