public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/14225] New: when using gcj cni calls within a pthread i get a segfault
@ 2004-02-20 11:59 sturmf at in dot tum dot de
  2004-02-20 12:01 ` [Bug libgcj/14225] " sturmf at in dot tum dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sturmf at in dot tum dot de @ 2004-02-20 11:59 UTC (permalink / raw)
  To: gcc-bugs

I have this small testprogram which when executed returns a segfault.
The problem seems to be when I start using cni calls in pthreads.
I already searched the web for any obvious mistakes I made.

The gcc version is:
gcc (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)

gcc -v results in:
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: /var/tmp/portage/gcc-3.3.2-r5/work/gcc-3.3.2/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++,f77,objc,java --enable-threads=posix --enable-long-long
--disable-checking --enable-cstdio=stdio --enable-clocale=generic
--enable-__cxa_atexit --enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3
--with-local-prefix=/usr/local --enable-shared --enable-nls
--without-included-gettext --x-includes=/usr/X11R6/include
--x-libraries=/usr/X11R6/lib --enable-interpreter --enable-java-awt=xlib
--with-x --disable-multilib
Thread model: posix
gcc version 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)

To build the program I used:
g++ -Wall -g -o crashme crashme.cpp -L/usr/lib -lpthread -lgcj

The compiler output:
It did not produce any warnings/errors

The program (there was no button to attach a file so here it is inline)

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
                                                                                
#include <gcj/cni.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
#include <java/lang/Throwable.h>
                                                                                
                                                                                
using namespace java::lang;
                                                                                
void *testThread(void *threadid) {
                                                                                
        //JvAttachCurrentThread(NULL, NULL); Does not work would crash immediately
                                                                                
        // Here should now be some cni calls
        String *message = JvNewStringLatin1("Hello from C++");
        JvInitClass(&System::class$);
        System::out->println(message);
                                                                                
        while (1) {
                std::cout << "in thread"<< std::endl;
        }
}
                                                                                
                                                                               
                                                                         
int main(int argc, char **argv)
{
        try
        {
                JvCreateJavaVM(NULL);
                // attach current thread to java. should have no sideeffects if
already attached
                JvAttachCurrentThread(NULL, NULL);
        }
        catch (java::lang::Throwable *t)
        {
                throw t;
        }
                                                                                
        pthread_t threads[1];
        int rc;
                                                                                
        // Now create the thread
        rc = pthread_create(&threads[0], NULL, testThread, (void *)0);
        if (rc){
                printf("ERROR; return code from pthread_create() is %d\n", rc);
                exit(-1);
        }
                                                                                
        while (1) {
                sleep(10);
        }
}

Hope this helps to find the bug!

Thanks a lot, Fabian

-- 
           Summary: when using gcj cni calls within a pthread i get a
                    segfault
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sturmf at in dot tum dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14225


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libgcj/14225] when using gcj cni calls within a pthread i get a segfault
  2004-02-20 11:59 [Bug libgcj/14225] New: when using gcj cni calls within a pthread i get a segfault sturmf at in dot tum dot de
@ 2004-02-20 12:01 ` sturmf at in dot tum dot de
  2004-02-20 12:08 ` sturmf at in dot tum dot de
  2004-02-20 16:40 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: sturmf at in dot tum dot de @ 2004-02-20 12:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sturmf at in dot tum dot de  2004-02-20 12:01 -------
Created an attachment (id=5777)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5777&action=view)
The program producing the bug

This file was created with:
g++ -Wall -g -o savetemp crashme.cpp -L/usr/lib -lpthread -lgcj -save-temps


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14225


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libgcj/14225] when using gcj cni calls within a pthread i get a segfault
  2004-02-20 11:59 [Bug libgcj/14225] New: when using gcj cni calls within a pthread i get a segfault sturmf at in dot tum dot de
  2004-02-20 12:01 ` [Bug libgcj/14225] " sturmf at in dot tum dot de
@ 2004-02-20 12:08 ` sturmf at in dot tum dot de
  2004-02-20 16:40 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: sturmf at in dot tum dot de @ 2004-02-20 12:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From sturmf at in dot tum dot de  2004-02-20 12:08 -------
Damn i forgot to add the gdb output, sorry.

Here it is

(gdb) run
Starting program: /home/sturm/crashme/crashme
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 6884)]
[New Thread 32769 (LWP 6886)]
[New Thread 16386 (LWP 6887)]
[New Thread 32771 (LWP 6888)]
 
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 32771 (LWP 6888)]
0x405b34c3 in GC_local_malloc_atomic () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4
(gdb) bt
#0  0x405b34c3 in GC_local_malloc_atomic () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4
#1  0x403e4dbe in _Jv_AllocPtrFreeObject () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4
#2  0x4040c310 in _Jv_AllocString () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4
#3  0x4040c3a2 in _Jv_NewStringLatin1 () from
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4
#4  0x08048de0 in JvNewStringLatin1 (bytes=0x8048f40 "Hello from C++") at cni.h:65
#5  0x08048c36 in testThread(void*) (threadid=0x0) at crashme.cpp:19
#6  0x40033f60 in pthread_start_thread () from /lib/libpthread.so.0
#7  0x40034062 in pthread_start_thread_event () from /lib/libpthread.so.0
#8  0x40a0747a in clone () from /lib/libc.so.6
(gdb) info threads
* 4 Thread 32771 (LWP 6888)  0x405b34c3 in GC_local_malloc_atomic ()
   from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/libgcj.so.4
  3 Thread 16386 (LWP 6887)  0x40036704 in __pthread_sigsuspend () from
/lib/libpthread.so.0
  2 Thread 32769 (LWP 6886)  0x40959731 in kill () from /lib/libc.so.6
  1 Thread 16384 (LWP 6884)  0x40036704 in __pthread_sigsuspend () from
/lib/libpthread.so.0
(gdb)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14225


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug libgcj/14225] when using gcj cni calls within a pthread i get a segfault
  2004-02-20 11:59 [Bug libgcj/14225] New: when using gcj cni calls within a pthread i get a segfault sturmf at in dot tum dot de
  2004-02-20 12:01 ` [Bug libgcj/14225] " sturmf at in dot tum dot de
  2004-02-20 12:08 ` sturmf at in dot tum dot de
@ 2004-02-20 16:40 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-20 16:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-20 16:40 -------
This is a dup of bug 13212.

*** This bug has been marked as a duplicate of 13212 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14225


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-02-20 16:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-20 11:59 [Bug libgcj/14225] New: when using gcj cni calls within a pthread i get a segfault sturmf at in dot tum dot de
2004-02-20 12:01 ` [Bug libgcj/14225] " sturmf at in dot tum dot de
2004-02-20 12:08 ` sturmf at in dot tum dot de
2004-02-20 16:40 ` pinskia at gcc dot gnu dot org

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).