Bug 80992

Summary: abort() sometimes not caught by gdb depending on thread library
Product: Base System Reporter: Pete French <petefrench>
Component: threadsAssignee: freebsd-threads (Nobody) <threads>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: jhb, pete
Priority: Normal    
Version: 5.4-RELEASE   
Hardware: Any   
OS: Any   

Description Pete French 2005-05-13 18:40:02 UTC
	

	When an unknown method is called in /usr/lib/libobjc.a it
	calls abort() to halt the program with a SIGABRT. Running
	such a program under gdb should then allow you to trace the
	point of the call.

	If the program is linked with -lthr then this works. If it
	is linked with -lpthread then this does not work, and gdb
	says "The program no longer exists."

	This works on FreeBSD 4 and all other operating systems I
	have tried it on. It also works, as stated, with libthr
	on FreeBSD 5. The problem seems to be specific to libpthread

	This has only shown up when trying to debug threaded code,
	but the fact it is specific to a thread library and that
	the code behaves everywhere else makes me wonder if something more
	sinister is going on inside pthread.

Fix: 

This is only an issue when debugging, and if I need to track
	down a bad method call I can always compile and run with libthr
	in order to find it. Annoying but not the end of the world.
How-To-Repeat: 
	Simple test code:

	#include <stdio.h>
	#include <objc/objc.h>
	#include <objc/objc-api.h>
	#include <objc/Object.h>

	int
	main(int argc, char *argv[])
	{
        	id my_test = [Object new];
        	[my_test a_missing_method];
        	return 0;
	}

	Compile with "cc -g test.m -lobj -lpthread" and run under gdb.

	Compiling with "cc -g test.m -lobj -lthr" behaves as expected.
Comment 1 Pete French 2005-06-13 16:09:52 UTC
A bit more info - this problem seems to be related to the scope of the threads
as if I run the test program with LIBPTHREAD_SYSTEM_SCOPE defined then
the debugger catches the abort correctly and lets me trace the offending
method call.
Comment 2 John Baldwin freebsd_committer freebsd_triage 2016-07-01 15:04:18 UTC
libkse is no longer supported and libthr is the only threading library used by modern versions of FreeBSD.
Comment 3 Pete French 2016-07-01 15:11:19 UTC
Heh, indeed! In addition modern FreeBSD has no objective c runtime and doesnt have the GNU compiler, so all kind of moot! Thanks for looking through. I do wonder what it was, however.