Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core dump in GC_push_all_stacks (collecting from unknown thread) #333

Closed
thanhtien501 opened this issue Sep 24, 2020 · 4 comments
Closed

Comments

@thanhtien501
Copy link

I'm using bdwgc. it is quite useful but sometimes I run into the issue:

#0 0xb680c6a8 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1 0xb680d924 in __GI_abort () at abort.c:89
#2 0x0104bec4 in GC_push_all_stacks ()
#3 0x01043edc in GC_mark_some ()
#4 0x0104e0a8 in GC_stopped_mark ()
#5 0x0104eba8 in GC_try_to_collect_inner ()
#6 0x0104f560 in GC_collect_or_expand ()
#7 0x0104f7ac in GC_allocobj ()
#8 0x01040af8 in GC_generic_malloc_inner ()
#9 0x01040c4c in GC_generic_malloc ()
#10 0x01040f14 in GC_malloc_kind_global ()
#11 0x001c9464 in pal_mem_calloc (type=MTYPE_LIST_NODE, size=12) at pal_memory.c:65
#12 0xb6bda048 in mfh_calloc () from /usr/lib/lib_libshared.so
#13 0xb6bcb16c in listnode_add () from /usr/lib/lib_libshared.so
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

I'm using gc 8 .0.4 and configure with enable-threads=posix, enable-thread-local-alloc, enable-parallel-mark.

please give a hand on the issue: how to avoid or anyway to fix it?

@ivmai
Copy link
Owner

ivmai commented Sep 24, 2020

Which operating system?
Which error message is printed?
Is this reproducible with bdwgc from master branch?

@thanhtien501
Copy link
Author

Which operating system?: linux-3.6.5 on arm embedded
Which error message is printed? not sure, but i see the "Collecting from unknown thread" is printed out, i think it is from gc
Is this reproducible with bdwgc from master branch? i will try your suggestion if possible because it is a live system. So far, the issue has not occurred on test lab.

@thanhtien501
Copy link
Author

thanhtien501 commented Sep 28, 2020

hi, I tried to reproduce the issue on 8.04 release by the following code:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include "leak_detector.h"
#include "gc.h"

void *myThreadFun(void *vargp)
{
    int * p;
    int i;

    p = (int*) GC_MALLOC(sizeof(int));

    while(i<5)
    {
        sleep(1);
        printf("%d\n",i);
        i++;
    }
    CHECK_LEAKS();
    printf("return from thread\n");
    return NULL;
}

int main(void) {
    GC_set_find_leak(1);                         */

    GC_INIT();  /* Needed if thread-local allocation is enabled.        */

    pthread_t thread_id;
    printf("Before Thread\n");
   pthread_create(&thread_id, NULL, myThreadFun, NULL);  
   pthread_join(thread_id, NULL);  
    printf("After Thread\n");

    return 0;
}

then I can see the core dump:

# ./leak_test1 
Before Thread
0
1
2
3
4
Collecting from unknown thread
Aborted (core dumped)
# ls
core-leak_test1-6-0-0-3237-6757  syslog
leak_test1
# gdb -c core-leak_test1-6-0-0-3237-6757 leak_test1 
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-buildroot-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from leak_test1...done.
[New LWP 3238]
[New LWP 3237]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
Core was generated by `./leak_test1'.
Program terminated with signal SIGABRT, Aborted.
#0  0xb6df86a8 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:55
55	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0xb6df86a8 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:55
#1  0xb6df9924 in __GI_abort () at abort.c:89
#2  0x0001bd80 in GC_push_all_stacks ()
#3  0x000138fc in GC_mark_some ()
#4  0x00009d18 in GC_stopped_mark ()
#5  0x0000a818 in GC_try_to_collect_inner ()
#6  0x0000aab0 in GC_try_to_collect_general ()
#7  0x0000ab6c in GC_gcollect ()
#8  0x00009644 in myThreadFun ()
#9  0xb6eeee30 in start_thread () from /lib/libpthread.so.0
#10 0xb6e88bb0 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:89
   from /lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

example.txt

@ivmai ivmai changed the title Core dump in GC_push_all_stacks Core dump in GC_push_all_stacks (collecting from unknown thread) Oct 9, 2020
@ivmai
Copy link
Owner

ivmai commented Apr 5, 2023

The issue is on your side: please change this code in your sample:

#include <pthread.h>
#include "leak_detector.h"
#include "gc.h"

to

#define GC_THREADS
#include "leak_detector.h"
#include <pthread.h>

(i.e. there should be GC_THREADS defined and gc-specific includes should precede pthread.h)

@ivmai ivmai closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants