Skip to content

ctfmerge gets a segmentation fault when merging large set of objects on Ubuntu 12.04 X86_64 machine #92

@shrikanth07

Description

@shrikanth07

The machine I am building on is a Ubuntu 12.0.4 X86_64 version and the CTF tools are built 64 bit. There is a large set of object files around 200+ which are compiled,linked to create a kernel module. The ctfconvert builds the .SUNW_ctf sections for each object file but when merging ctfmerge blows up, gets a segmentation fault. The command is ctfmerge -L VERSION -g -o module.ko.debug <list of object .o's>. I enabled the debugs in the environment i.e CTFMERGE_DEBUG_LEVEL 7 and CTFMERGE_DEBUG_PARSE 1 and have the following snapshot before the crash
Average: 0.35
DEBUG: 354588416: entering first barrier
DEBUG: 346195712: entering second barrier
DEBUG: 346195712: phase 1 complete
DEBUG: 371373824: entering second barrier
DEBUG: 354588416: doing work in first barrier
DEBUG: clearing slot 0 (0) (saving 5)
DEBUG: clearing slot 1 (1) (saving 5)
DEBUG: clearing slot 2 (2) (saving 5)
DEBUG: clearing slot 3 (3) (saving 5)
DEBUG: clearing slot 4 (4) (saving 5)
DEBUG: 362981120: entering second barrier
DEBUG: phase one done: donequeue has 75 items
DEBUG: 354588416: ninqueue is 149, 75 on queue
DEBUG: 354588416: entering second barrier

The crash backtrace
(gdb) bt
#0 sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:45
#1 0x00000000004029a5 in barrier_wait (bar=0x6333e0) at barrier.c:107
#2 0x0000000000403388 in worker_thread (wq=0x633280) at ctfmerge.c:547
#3 0x00007ffff7498e9a in start_thread (arg=0x7ffff5eca700) at pthread_create.c:308
#4 0x00007ffff71c53fd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5 0x0000000000000000 in ?? ()

(gdb) frame 1
#1 0x00000000004029a5 in barrier_wait (bar=0x6333e0) at barrier.c:107

107
(gdb) l
102 pthread_mutex_lock(&bar->bar_lock);
103
104 if (++bar->bar_numin < bar->bar_nthr) {
105 pthread_mutex_unlock(&bar->bar_lock);
106 sem_wait(bar->bar_sem);
107
108 return (0);
109
110 } else {
111 int i;
(gdb) p bar[0]
$1 = {bar_lock = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}, bar_numin = 1, bar_sem = 0x0,
bar_nthr = 5}

Further, an experimental nit in barrier.c

diff --git a/cmd/ctfconvert/barrier.c b/cmd/ctfconvert/barrier.c
index 94bb78d..8c37bff 100644
--- a/cmd/ctfconvert/barrier.c
+++ b/cmd/ctfconvert/barrier.c
@@ -90,8 +90,9 @@ void
barrier_init(barrier_t *bar, int nthreads)
{
pthread_mutex_init(&bar->bar_lock, NULL);

  •   bar->bar_sem = sem_open("ctfmerge_barrier", O_CREAT | O_EXCL);
    
  •   bar->bar_sem = sem_open("ctfmerge_barrier", O_CREAT);
    
  •    if (bar->bar_sem == SEM_FAILED)
    
  •            perror("sem_open failed");
     bar->bar_numin = 0;
     bar->bar_nthr = nthreads;
    

}

The perror reports EEXISTS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions