On 13 November 2015 at 07:43, Willem Ferguson
<[email protected]> wrote:
> abort() called
> *** error for object 0x60000008edd0: pointer being freed was not allocated
>
>
> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
> 0   libsystem_kernel.dylib         0x00007fff92e95286 __pthread_kill + 10
> 1   libsystem_c.dylib             0x00007fff861209b3 abort + 129
> 2   libsystem_malloc.dylib         0x00007fff8bf721cb free + 428
> 3   org.subsurface-divelog         0x0000000101478794 free_prefs + 20
> 4   org.subsurface-divelog         0x00000001011efe8d main + 2301
> 5   org.subsurface-divelog         0x00000001011ef584 start + 52
>

the report is obvious, but on a quick look @ the source i can't pin
point the exect free() call which is the problem one.
all preferences seem to be allocated with with string_copy() and if a
preference is NULL free() should not be a problem.

i can't debug that on Win32, because my fake console exits too early.
the proposed patch is the following: make free_prefs() a NOP, until we
refactor the global preferences.
the one-time leaks won't do much harm.

patch attached.

lubomir
--

P.S. if someone has means to debug this properly, please go ahead.
From 98aa3a78f7b10d4a95cc83cecb5af151eecbcda0 Mon Sep 17 00:00:00 2001
From: "Lubomir I. Ivanov" <[email protected]>
Date: Fri, 13 Nov 2015 15:20:48 +0200
Subject: [PATCH] subsurfacestartup.c: leave free_prefs() empty

There is a bug on OSX where free() is called on non-allocated
memory in free_prefs(). Most of the preferences are not freed
in free_prefs() while copy_string() is used on them, so let's
not free() any pointers in free_prefs() and leave them
as one-time leaks.

Signed-off-by: Lubomir I. Ivanov <[email protected]>
--
a "free of non-allocated pointer" was reported by Willem on
OSX. i can't debug that on Windows because the console here
exits before free_prefs() is even reached.

overall this change is harmless.

Tomaz did say that he has plans to remove the global prefs struct
at some point.
---
 subsurface-core/subsurfacestartup.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/subsurface-core/subsurfacestartup.c b/subsurface-core/subsurfacestartup.c
index 13cbbfa..8656f3f 100644
--- a/subsurface-core/subsurfacestartup.c
+++ b/subsurface-core/subsurfacestartup.c
@@ -311,11 +311,5 @@ void copy_prefs(struct preferences *src, struct preferences *dest)
  */
 void free_prefs(void)
 {
-	free((void*)prefs.default_cylinder);
-	free((void*)prefs.divelist_font);
-	free((void*)prefs.cloud_storage_password);
-	free(prefs.proxy_host);
-	free(prefs.proxy_user);
-	free(prefs.proxy_pass);
-	free(prefs.userid);
+	// nop
 }
-- 
1.7.11.msysgit.0

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to