Ciężko to zdebugować, bo pthread miesza na stosie (użycie sigsetjmp).

Czy przy kompilacji były jakiekolwiek błędy? Jakie flagi do configure użyłeś (zgaduję, że m.in. --with-pthread=yes). Możesz sprawdzić, czy te makra są zdefiniowane: __GNUC__, __EXCEPTIONS, __cplusplus (tuż przed includowaniem pthread.h w resolver.c).

Spróbuj zaaplikować łatkę z załącznika, rozwieje parę wątpliwości:
- czy wątek jest zabijany w jakimś niespodziewanym momencie (patrz linijka pthread_setcancelstate i jej komentarz) - ile razy jest wywoływany gg_resolver_pthread_cleanup - zagnieżdżone pthread_cleanup_push nie powinny robić szkód, ale nigdy nie wiadomo

Przy okazji znalazłem jednego buga, ale nie podejrzewam, żeby był powiązany (dotyczy zachowania przy przepełnieniu pamięci). Ale nie zaszkodzi sprawdzić.

Możesz też printfować co linijkę, żeby wydobyć prawdziwy stos.

Dużo prościej by mi było samemu to debugować, niż ręcznie analizować kod - czy jest odpowiednik OBS dla fedory 21 (wersje 16-19 są dostępne nawet na serwerach opensuse), czy muszę instalować cały system?

Pozdrawiam,
Tomek

W dniu 12.12.2013 01:07, Dominik 'Rathann' Mierzejewski pisze:
Cześć,

On Tuesday, 12 November 2013 at 22:35, Wojtek Kaniewski wrote:
Szczegóły pod adresem http://libgadu.net/releases/1.12.0-rc1.html

Próbuję właśnie zbudować nową paczkę dla Fedory i o ile na F20 buduje
się bez problemów i testy przechodzi, o tyle na wersji rozwojowej
(Rawhide/F21) dostaję segmentation fault przy teście resolvera (ale
tylko na x86_32):

$ make check
[...]
Testing local pthread resolver
** gg_login(0xffd6338c: [uin=1, async=1, ...]);
** gg_watch_fd(0x82be028);
// gg_watch_fd() GG_STATE_RESOLVE_HUB_ASYNC
** gg_resolver_pthread_start(0x82be028, 0x82be0b4,
"appmsg.gadu-gadu.pl");
// gg_resolver_pthread_start() 0x82be1f0
** gg_event_free(0x82be1b0);
** gg_free_session(0x82be028);
Testing global default resolver in HTTP
=> -----BEGIN-HTTP-QUERY-----
GET /test HTTP/1.0

=> -----END-HTTP-QUERY-----
** gg_resolver_pthread_start(0x82be028, 0x82be074, "test");
// gg_resolver_pthread_start() 0x82be1f0
// gg_http_connect() resolver = 0x82be1f0
/bin/sh: line 5: 31811 Segmentation fault      (core dumped) ${dir}$tst
FAIL: resolver

$ gdb resolver core.30869
GNU gdb (GDB) Fedora 7.6.50.20130731-16.fc21
[...]
This GDB was configured as "i686-redhat-linux-gnu".
[...]
Reading symbols from
/builddir/build/BUILD/libgadu-1.12.0-rc1/test/automatic/resolver...done.
[New LWP 30881]
[New LWP 30869]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Core was generated by `./resolver'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0xf770e480 in free@plt () from
/builddir/build/BUILD/libgadu-1.12.0-rc1/src/.libs/libgadu.so.3
(gdb) where
#0  0xf770e480 in free@plt () from 
/builddir/build/BUILD/libgadu-1.12.0-rc1/src/.libs/libgadu.so.3
#1  0xf772aa23 in gg_resolver_cleaner (data=0xf6db8288) at resolver.c:69
#2  __pthread_cleanup_routine (__frame=<synthetic pointer>) at 
/usr/include/pthread.h:622
#3  gg_resolver_run (fd=<optimized out>, hostname=<optimized out>, 
pthread=pthread@entry=1) at resolver.c:283
#4  0xf772aa56 in gg_resolver_pthread_thread (arg=0x8e571f0) at resolver.c:524
#5  0xf75bafda in start_thread () from /lib/libpthread.so.0
#6  0xf74e919e in clone () from /lib/libc.so.6

Jakieś pomysły, jak to zdebugować?

Pozdrawiam,
Dominik

diff --git a/src/resolver.c b/src/resolver.c
index c218572..578668a 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -173,7 +173,8 @@ int gg_gethostbyname_real(const char *hostname, struct in_addr **result, unsigne
 #endif
 
 			if (*result == NULL)
-				return -1;
+				ret = ENOMEM; /* to i tak nic nie daje, nie używamy później ret */
+			else {
 
 			/* Kopiuj */
 
@@ -185,6 +186,7 @@ int gg_gethostbyname_real(const char *hostname, struct in_addr **result, unsigne
 			*count = i;
 
 			res = 0;
+			} /* *result != NULL */
 		}
 
 #ifdef GG_CONFIG_HAVE_PTHREAD
@@ -496,6 +498,9 @@ static void gg_resolver_pthread_cleanup(void **priv_data, int force)
 {
 	struct gg_resolver_pthread_data *data;
 
+	gg_debug(GG_DEBUG_FUNCTION, "** gg_resolver_pthread_cleanup(%p [%p], %d);\n",
+		priv_data, (priv_data ? *priv_data : NULL), force);
+
 	if (priv_data == NULL || *priv_data == NULL)
 		return;
 
@@ -521,6 +526,8 @@ static void *gg_resolver_pthread_thread(void *arg)
 {
 	struct gg_resolver_pthread_data *data = arg;
 
+	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); /* spróbuj z tą linijką i bez */
+
 	if (gg_resolver_run(data->wfd, data->hostname, 1) == -1)
 		pthread_exit((void*) -1);
 	else

Attachment: smime.p7s
Description: Kryptograficzna sygnatura S/MIME

_______________________________________________
libgadu-devel mailing list
libgadu-devel@lists.ziew.org
http://lists.ziew.org/mailman/listinfo/libgadu-devel

Reply via email to