From: "Torbjörn Eriksson" <pt96ter@palantir.proj.ide.hk-r.se>
To: egcs@cygnus.com
Subject: multithread with egcs/(C++) and RedHat 5.0
Date: Wed, 22 Apr 1998 08:31:00 -0000 [thread overview]
Message-ID: <353DE2B3.989E7D86@palantir.proj.ide.hk-r.se> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2735 bytes --]
Hello,
First of all, I apologize if this question shouldn't bee here at all.
I'm quite new at programming threads, so I don't really know if this
problem is related to egcs at all.
Background: We're 4 students working on a project at University of
Karlskrona-Ronneby i southern Sweden. We decided to develop our project
in C++ on a Linux box, (RedHat 5.0). After doing some research we found
out that gcc ver. 2.7.2 doesn't work with threads, and that egcs would.
Our problem is that system calls like readdir_r and localtime_r causes
segmention faults, this is a printout from gdb.
#0 0x4004c93c in __pthread_mutex_lock () at mutex.c:135
#1 0x4004e28c in __fresetlockfiles () at lockfile.c:87
#2 0x400a7053 in _IO_fread (buf=0xbffff7a0, size=44, count=1,
fp=0x804e250)
at iofread.c:44
#3 0x400c546e in __tzfile_compute (timer=1074773704,
use_localtime=1074807804, leap_correct=0xbffff860,
leap_hit=0xbffff8cc)
at tzfile.c:283
#4 0x400c4413 in tzset_internal () at tzset.c:197
#5 0x400c518c in __tz_convert () at tzset.c:561
#6 0x400c1c2f in localtime (t=0xbffff8cc) at localtime.c:49
#7 0x8048f1c in ThreadClass::Notify () at ThreadClass.cc:103
#8 0x8048e48 in ThreadClass::ScanDir (this=0x804c1d0) at
ThreadClass.cc:66
#9 0x8048daa in ThreadClass::Listen (this=0x804c1d0) at
ThreadClass.cc:44
#10 0x8048bfe in main () at main.cc:23
I do'nt know, but I suspect that we might start the thread in an illegal
way
pthread_t
ThreadClass::Run()
{
pthread_attr_init(&myThreadAttr);
pthread_attr_setscope(&myThreadAttr, PTHREAD_SCOPE_SYSTEM);
if (pthread_create(&myThread, &myThreadAttr, SpawnThread, this)==0)
{
return myThread;
}else
return (0);
}
// this one is declared as static void* in ThreadClass.hh
// ThreadClass::Listen is a ordinary member function returning void*
void*
ThreadClass::SpawnThread(void* arg)
{
return (((ThreadClass *) arg)->Listen());
}
Listen memberfunction just sleeps for a while and then it calls ScanDir
that does a readdir_r on a directory, when a file is found it calls
Notify with the filename
void
ThreadClass::Notify(char* filename)
{
struct stat sbuf;
struct tm tptr;
if (!lstat(filename, &sbuf))
{
localtime_r(&(sbuf.st_mtime), &tptr);
}
}
In localtime_r, the program causes a segm. fault
We have installed
gcc version egcs-2.90.27 980315 (egcs-1.0.2 release)
and the prerequisits that the rpm asked for.
We will be very grateful for any help or suggestions, and, once again,
I'm sorry if this question doesn't belong here, but after browsing
through this mail archive and searching the net, it seemed to be a good
place to start.
Thorbjörn Eriksson
pt96ter@student.hk-r.se
pt96ter@palantir.proj.ide.hk-r.se
next reply other threads:[~1998-04-22 8:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-22 8:31 Torbjörn Eriksson [this message]
1998-04-22 15:21 Kaz Kylheku
1998-04-22 20:43 ` Torbjörn Eriksson
1998-04-23 23:23 ` Niku Kaitaniemi
1998-04-24 11:56 ` Jeffrey A Law
1998-04-25 7:14 ` Michael Alan Dorman
1998-04-25 16:18 ` Jeffrey A Law
[not found] <Pine.LNX.3.96.980422125036.3537A-100000@earth.terran.org>
1998-04-22 20:43 ` Torbjörn Eriksson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=353DE2B3.989E7D86@palantir.proj.ide.hk-r.se \
--to=pt96ter@palantir.proj.ide.hk-r.se \
--cc=egcs@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).