[
https://issues.apache.org/jira/browse/TS-427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12910842#action_12910842
]
John Plevyak commented on TS-427:
---------------------------------
There is a bug in clang.
Here is the code:
Action *
Cache::open_read(Continuation * cont, CacheKey * key, CacheFragType type, char
*hostname, int host_len)
{
if (!CACHE_READY(type)) {
cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_NOT_READY);
return ACTION_RESULT_DONE;
}
ink_assert(caches[type] == this);
Part *part = key_to_part(key, hostname, host_len);
Dir result, *last_collision = NULL;
ProxyMutex *mutex = cont->mutex;
OpenDirEntry *od = NULL;
CacheVC *c = NULL;
{
CACHE_TRY_LOCK(lock, part->mutex, mutex->thread_holding);
if (!lock || (od = part->open_read(key)) || dir_probe(key, part, &result,
&last_collision)) {
c = new_CacheVC(cont);
SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead);
c->vio.op = VIO::READ;
c->base_stat = cache_read_active_stat;
CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE);
c->first_key = c->key = c->earliest_key = *key;
c->part = part;
c->frag_type = type;
c->od = od;
}
if (!c)
goto Lmiss;
if (!lock) {
CONT_SCHED_LOCK_RETRY(c);
return &c->_action;
}
if (c->od)
goto Lwriter;
c->dir = result;
c->last_collision = last_collision;
switch(c->do_read_call(&c->key)) {
case EVENT_DONE: return ACTION_RESULT_DONE;
case EVENT_RETURN: goto Lcallreturn;
default: return &c->_action;
}
}
Lmiss:
CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat);
cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *) -ECACHE_NO_DOC);
return ACTION_RESULT_DONE;
Lwriter:
SET_CONTINUATION_HANDLER(c, &CacheVC::openReadFromWriter);
if (c->handleEvent(EVENT_IMMEDIATE, 0) == EVENT_DONE)
return ACTION_RESULT_DONE;
return &c->_action;
Lcallreturn:
if (c->handleEvent(AIO_EVENT_DONE, 0) == EVENT_DONE)
return ACTION_RESULT_DONE;
return &c->_action;
}
The stack trace says that we are in a call at
SET_CONTINUATION_HANDLER(c, &CacheVC::openReadFromWriter);
if (c->handleEvent(EVENT_IMMEDIATE, 0) == EVENT_DONE)
<<<<<<<<<<<<<<<<<<<<<<<< HERE
return ACTION_RESULT_DONE;
return &c->_action;
But that the destructor for the object created at:
CACHE_TRY_LOCK(lock, part->mutex, mutex->thread_holding);
<<<<<<<<<<<<<<<<<<<<<<<< HERE
is not getting called.
That object is a MutexTryLock.
The assembly code makes this clear. That code is attached at the bottom, but
the critical bits
are this call path:
1) openReadFromWriter is only accessible from LBB21_53
2) which is only accessible from LBB21_30
3) which must pass through the setting of the OpenReadStartHead via
SET_CONTINUATION_HANDLER
which is in the liveness block of 'lock'
4) ~MutexTryLock does not appear along this path
There are 2 instances of the destructor (~MutexTryLock()) being called, one
below LBB21_39 which is in the path
after the (inlined) do_read_call() and the other is in the exception block at
the end of the function.
I have tried to make a smaller test case, to no avail. I am not sure what the
trigger is.
.text
.globl Cache::open_read(Continuation*, INK_MD5*, CacheFragType, char*,
int)
.align 16, 0x90
.type Cache::open_read(Continuation*, INK_MD5*, CacheFragType, char*,
int),@function
Cache::open_read(Continuation*, INK_MD5*, CacheFragType, char*, int):
.Leh_func_begin21:
.Lfunc_begin21:
.Ltmp434:
pushq %rbp
.Ltmp431:
movq %rsp, %rbp
.Ltmp432:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $88, %rsp
.Ltmp433:
movl %r9d, %ebx
.Ltmp435:
movq %r8, %r14
.Ltmp436:
.Ltmp437:
movq %rdx, %r15
.Ltmp438:
.Ltmp439:
.Ltmp440:
.Ltmp441:
movq CacheProcessor::cache_re...@gotpcrel(%rip), %rax
movl (%rax), %eax
btl %ecx, %eax
movq %rsi, -88(%rbp)
jb .LBB21_4
.Ltmp442:
.Ltmp443:
.Ltmp444:
.Ltmp445:
movq %rsi, %rdi
movq 8(%rdi), %r14
addq 16(%rdi), %rdi
movq %rdi, -88(%rbp)
testb $1, %r14b
je .LBB21_3
movq -88(%rbp), %rdi
movq (%rdi), %r15
movq -1(%r14,%r15), %r14
.LBB21_3:
movl $1103, %esi
movq $-20407, %rdx
movq -88(%rbp), %rdi
callq *%r14
jmp .LBB21_51
.LBB21_4:
movl %ecx, %eax
movl %eax, -116(%rbp)
movq %rdi, %r12
.Ltmp446:
.Ltmp447:
movl %eax, %eax
movq cac...@gotpcrel(%rip), %rcx
cmpq %r12, (%rcx,%rax,8)
je .LBB21_6
leaq .L.str(%rip), %rdi
leaq .L.str1(%rip), %rsi
movl $39, %edx
callq _ink_ass...@plt
.LBB21_6:
movl %ebx, %ecx
movq %r14, %rdx
.Ltmp448:
movq %r12, %rdi
movq %r15, %rsi
callq Cache::key_to_part(INK_MD5*, char*, int)@PLT
movq %rax, -96(%rbp)
movw $0, -48(%rbp)
movq $0, -56(%rbp)
.Ltmp449:
movq $0, -64(%rbp)
.Ltmp450:
movq 32(%rax), %r8
.Ltmp451:
.Ltmp452:
.Ltmp453:
.Ltmp454:
.Ltmp455:
.Ltmp456:
.Ltmp457:
.Ltmp458:
.Ltmp459:
.Ltmp460:
.Ltmp461:
.Ltmp462:
movq -88(%rbp), %rdi
movq 32(%rdi), %rax
.Ltmp463:
.Ltmp464:
movq %rax, -104(%rbp)
movq 56(%rax), %r9
leaq -80(%rbp), %rdi
.Ltmp465:
.Ltmp466:
.Ltmp467:
.Ltmp468:
.Ltmp469:
.Ltmp470:
.Ltmp471:
.Ltmp472:
leaq .L.str1(%rip), %rsi
movl $47, %edx
movq $0, -112(%rbp)
xorl %ecx, %ecx
callq MutexTryLock::MutexTryLock(char const*, int, char const*,
ProxyMutex*, EThread*)@PLT
testb $1, -72(%rbp)
je .LBB21_12
.Ltmp473:
.Ltmp474:
.Ltmp475:
.Ltmp409:
.Ltmp476:
movq -96(%rbp), %rax
leaq 464(%rax), %rdi
movq %r15, %rsi
callq OpenDir::open_read(INK_MD5*)@PLT
.Ltmp410:
.Ltmp477:
.Ltmp478:
testq %rax, %rax
je .LBB21_10
movq %rax, -112(%rbp)
jmp .LBB21_12
.LBB21_10:
.Ltmp411:
leaq -56(%rbp), %rdx
leaq -64(%rbp), %rcx
movq %r15, %rdi
movq -96(%rbp), %rsi
callq dir_probe(INK_MD5*, Part*, Dir*, Dir**)@PLT
.Ltmp412:
testl %eax, %eax
je .LBB21_40
.LBB21_12:
.Ltmp479:
.Ltmp413:
movq -88(%rbp), %rdi
callq new_CacheVC(Continuation*)@PLT
.Ltmp414:
movq %rax, %rbx
.Ltmp480:
movq CacheVC::openReadStartHead(int, Event*)@GOTPCREL(%rip), %rax
movq %rax, 8(%rbx)
movq $0, 16(%rbx)
leaq .L.str2(%rip), %rax
movq %rax, 24(%rbx)
.Ltmp481:
movl $1, 640(%rbx)
.Ltmp482:
movl $13, 856(%rbx)
.Ltmp483:
movq cache_...@gotpcrel(%rip), %rax
movq (%rax), %r14
movq -104(%rbp), %rax
movq 56(%rax), %r12
.Ltmp484:
cmpl $13, 20(%r14)
.Ltmp485:
.Ltmp486:
.Ltmp487:
.Ltmp488:
.Ltmp489:
.Ltmp490:
.Ltmp491:
.Ltmp492:
jg .LBB21_15
.Ltmp415:
leaq .L.str93(%rip), %rdi
leaq .L.str94(%rip), %rsi
movl $115, %edx
callq _ink_ass...@plt
.Ltmp416:
.LBB21_15:
.Ltmp493:
testq %r12, %r12
jne .LBB21_17
.Ltmp494:
movq Thread::thread_data_...@gotpcrel(%rip), %r12
movl (%r12), %edi
.Ltmp495:
.Ltmp496:
callq pthread_getspeci...@plt
.Ltmp497:
.Ltmp498:
movq %rax, %r12
.LBB21_17:
.Ltmp499:
movq (%r14), %rax
.Ltmp500:
.Ltmp501:
incq 416(%rax,%r12)
.Ltmp502:
incq 424(%rax,%r12)
.Ltmp503:
.Ltmp504:
movq -96(%rbp), %rax
movq 4688(%rax), %rax
movq 48(%rax), %r14
movq -104(%rbp), %rax
movq 56(%rax), %r12
.Ltmp505:
movslq 856(%rbx), %r13
testq %r13, %r13
.Ltmp506:
.Ltmp507:
.Ltmp508:
.Ltmp509:
.Ltmp510:
.Ltmp511:
js .LBB21_19
.Ltmp512:
cmpl %r13d, 20(%r14)
jg .LBB21_20
.LBB21_19:
.Ltmp417:
leaq .L.str93(%rip), %rdi
leaq .L.str94(%rip), %rsi
movl $115, %edx
callq _ink_ass...@plt
.Ltmp418:
.LBB21_20:
.Ltmp513:
testq %r12, %r12
jne .LBB21_22
.Ltmp514:
movq Thread::thread_data_...@gotpcrel(%rip), %r12
movl (%r12), %edi
.Ltmp515:
.Ltmp516:
callq pthread_getspeci...@plt
.Ltmp517:
.Ltmp518:
movq %rax, %r12
.LBB21_22:
addq (%r14), %r12
.Ltmp519:
.Ltmp520:
shlq $5, %r13
incq (%r13,%r12)
.Ltmp521:
incq 8(%r13,%r12)
.Ltmp522:
movq (%r15), %rax
movq %rax, 96(%rbx)
movq 8(%r15), %rax
movq %rax, 104(%rbx)
.Ltmp523:
movq (%r15), %rax
movq %rax, 64(%rbx)
movq 8(%r15), %rax
movq %rax, 72(%rbx)
.Ltmp524:
movq (%r15), %rax
movq %rax, 80(%rbx)
movq 8(%r15), %rax
movq %rax, 88(%rbx)
.Ltmp525:
.Ltmp526:
movq -96(%rbp), %rax
movq %rax, 792(%rbx)
.Ltmp527:
movl -116(%rbp), %ecx
movl %ecx, 696(%rbx)
.Ltmp528:
movq -112(%rbp), %rax
movq %rax, 400(%rbx)
testq %rbx, %rbx
je .LBB21_40
testb $1, -72(%rbp)
.Ltmp529:
.Ltmp530:
.Ltmp531:
jne .LBB21_30
movq 32(%rbx), %rax
.Ltmp532:
movq 56(%rax), %r14
.Ltmp533:
.Ltmp534:
movq 2560(%r14), %rax
.Ltmp535:
.Ltmp536:
.Ltmp537:
.Ltmp538:
.Ltmp539:
.Ltmp540:
testq %rax, %rax
je .LBB21_26
.Ltmp541:
movq (%rax), %rcx
movq %rcx, 2560(%r14)
.Ltmp542:
decl 2552(%r14)
.Ltmp543:
movq eventalloca...@gotpcrel(%rip), %rcx
movq 48(%rcx), %rcx
movq %rcx, (%rax)
jmp .LBB21_28
.LBB21_26:
.Ltmp544:
.Ltmp422:
movq eventalloca...@gotpcrel(%rip), %rdi
callq ink_freelist_...@plt
.Ltmp423:
.Ltmp545:
.Ltmp546:
.Ltmp547:
movq eventalloca...@gotpcrel(%rip), %rcx
movq 48(%rcx), %rdx
movq %rdx, (%rax)
movq 56(%rcx), %rdx
movq %rdx, 8(%rax)
movq 64(%rcx), %rdx
movq %rdx, 16(%rax)
movq 72(%rcx), %rdx
movq %rdx, 24(%rax)
movq 80(%rcx), %rdx
movq %rdx, 32(%rax)
movq 88(%rcx), %rdx
movq %rdx, 40(%rax)
movq 96(%rcx), %rdx
movq %rdx, 48(%rax)
movq 104(%rcx), %rdx
movq %rdx, 56(%rax)
movq 112(%rcx), %rdx
movq %rdx, 64(%rax)
movq 120(%rcx), %rdx
movq %rdx, 72(%rax)
movq 128(%rcx), %rdx
movq %rdx, 80(%rax)
movq 136(%rcx), %rcx
movq %rcx, 88(%rax)
.Ltmp548:
.LBB21_28:
.Ltmp549:
movl $2, 44(%rax)
.Ltmp550:
.Ltmp551:
movq $0, 64(%rax)
.Ltmp552:
movq Thread::cur_t...@gotpcrel(%rip), %rcx
movq (%rcx), %rcx
.Ltmp553:
movq %rbx, 8(%rax)
.Ltmp554:
.Ltmp555:
addq $20000000, %rcx
.Ltmp556:
movq %rcx, 48(%rax)
.Ltmp557:
movq $0, 56(%rax)
.Ltmp558:
movl 40(%rax), %edx
andl $-5, %edx
.Ltmp559:
.Ltmp560:
testq %rcx, %rcx
sete %cl
.Ltmp561:
movzbl %cl, %ecx
shll $2, %ecx
.Ltmp562:
.Ltmp563:
.Ltmp564:
.Ltmp565:
addl %edx, %ecx
movl %ecx, 40(%rax)
.Ltmp566:
movl $0, 24(%rax)
.Ltmp424:
movq %r14, %rdi
movq %rax, %rsi
callq EThread::schedule_local(Event*)@PLT
.Ltmp425:
.Ltmp567:
.LBB21_29:
.Ltmp568:
addq $168, %rbx
jmp .LBB21_39
.Ltmp569:
.LBB21_30:
.Ltmp570:
cmpq $0, -112(%rbp)
jne .LBB21_53
.Ltmp571:
movw -48(%rbp), %ax
movw %ax, 136(%rbx)
movq -56(%rbp), %rax
movq %rax, 128(%rbx)
.Ltmp572:
movq -64(%rbp), %rax
movq %rax, 800(%rbx)
.Ltmp573:
.Ltmp574:
.Ltmp575:
movq $0, 904(%rbx)
.Ltmp576:
.Ltmp577:
leaq 64(%rbx), %rax
.Ltmp578:
movq %rax, 816(%rbx)
.Ltmp579:
movzwl 130(%rbx), %eax
movl %eax, %ecx
shrl $8, %ecx
andl $3, %ecx
leal (%rcx,%rcx,2), %ecx
movl $512, %edx
shll %cl, %edx
shrl $10, %eax
incl %eax
imull %edx, %eax
movq %rax, 480(%rbx)
.Ltmp580:
movq 8(%rbx), %rax
movq 16(%rbx), %rcx
testq %rcx, %rcx
setne %dl
testq %rax, %rax
setne %sil
cmpq CacheVC::dead(int, Event*)@GOTPCREL(%rip), %rax
jne .LBB21_35
andb %dl, %sil
cmpb $1, %sil
je .LBB21_35
.Ltmp426:
leaq .L.str58(%rip), %rdi
leaq .L.str59(%rip), %rsi
movl $635, %edx
callq _ink_ass...@plt
.Ltmp427:
movq 8(%rbx), %rax
movq 16(%rbx), %rcx
.LBB21_35:
movq %rax, 824(%rbx)
movq %rcx, 832(%rbx)
movq CacheVC::handleRead(int, Event*)@GOTPCREL(%rip), %rax
movq %rax, 8(%rbx)
movq $0, 16(%rbx)
.Ltmp428:
movl $4, %esi
xorl %edx, %edx
movq %rbx, %rdi
callq CacheVC::handleRead(int, Event*)@PLT
.Ltmp429:
.Ltmp581:
.Ltmp582:
cmpl $5, %eax
je .LBB21_56
testl %eax, %eax
jne .LBB21_29
movl $3, %ebx
.LBB21_39:
leaq -80(%rbp), %rdi
callq MutexTryLock::~MutexTryLock()@PLT
.Ltmp583:
.Ltmp584:
movq %rbx, %rax
jmp .LBB21_52
.LBB21_40:
.Ltmp585:
movq cache_...@gotpcrel(%rip), %rbx
movq (%rbx), %rbx
movq -104(%rbp), %rax
movq 56(%rax), %r14
.Ltmp586:
cmpl $15, 20(%rbx)
.Ltmp587:
.Ltmp588:
.Ltmp589:
.Ltmp590:
.Ltmp591:
.Ltmp592:
.Ltmp593:
.Ltmp594:
jg .LBB21_42
.Ltmp595:
leaq .L.str93(%rip), %rdi
leaq .L.str94(%rip), %rsi
movl $115, %edx
callq _ink_ass...@plt
.LBB21_42:
.Ltmp596:
testq %r14, %r14
jne .LBB21_44
.Ltmp597:
movq Thread::thread_data_...@gotpcrel(%rip), %r14
movl (%r14), %edi
.Ltmp598:
.Ltmp599:
callq pthread_getspeci...@plt
.Ltmp600:
.Ltmp601:
movq %rax, %r14
.LBB21_44:
.Ltmp602:
movq (%rbx), %rbx
.Ltmp603:
.Ltmp604:
incq 480(%rbx,%r14)
.Ltmp605:
incq 488(%rbx,%r14)
.Ltmp606:
.Ltmp607:
movq -96(%rbp), %rax
movq 4688(%rax), %rbx
movq 48(%rbx), %rbx
movq -104(%rbp), %rax
movq 56(%rax), %r14
.Ltmp608:
cmpl $15, 20(%rbx)
.Ltmp609:
.Ltmp610:
.Ltmp611:
.Ltmp612:
.Ltmp613:
.Ltmp614:
.Ltmp615:
.Ltmp616:
jg .LBB21_46
.Ltmp617:
leaq .L.str93(%rip), %rdi
leaq .L.str94(%rip), %rsi
movl $115, %edx
callq _ink_ass...@plt
.LBB21_46:
.Ltmp618:
testq %r14, %r14
jne .LBB21_48
.Ltmp619:
movq Thread::thread_data_...@gotpcrel(%rip), %r14
movl (%r14), %edi
.Ltmp620:
.Ltmp621:
callq pthread_getspeci...@plt
.Ltmp622:
.Ltmp623:
movq %rax, %r14
.LBB21_48:
.Ltmp624:
movq (%rbx), %rbx
.Ltmp625:
.Ltmp626:
incq 480(%rbx,%r14)
.Ltmp627:
incq 488(%rbx,%r14)
.Ltmp628:
.Ltmp629:
.Ltmp630:
.Ltmp631:
.Ltmp632:
movq -88(%rbp), %rdi
movq 8(%rdi), %rbx
addq 16(%rdi), %rdi
movq %rdi, -88(%rbp)
testb $1, %bl
je .LBB21_50
movq -88(%rbp), %rdi
movq (%rdi), %rax
movq -1(%rbx,%rax), %rbx
.LBB21_50:
movl $1103, %esi
movq $-20400, %rdx
movq -88(%rbp), %rdi
callq *%rbx
.LBB21_51:
movl $3, %eax
.Ltmp633:
.LBB21_52:
.Ltmp634:
addq $88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
ret
.LBB21_53:
.Ltmp635:
movq CacheVC::openReadFromWriter(int, Event*)@GOTPCREL(%rip), %rax
movq %rax, 8(%rbx)
.Ltmp636:
.Ltmp637:
.Ltmp638:
.Ltmp639:
movq $0, 16(%rbx)
leaq .L.str3(%rip), %rax
movq %rax, 24(%rbx)
movl $1, %esi
xorl %edx, %edx
movq %rbx, %rdi
callq CacheVC::openReadFromWriter(int, Event*)@PLT
.LBB21_54:
testl %eax, %eax
je .LBB21_51
.Ltmp640:
movq %rbx, %rax
addq $168, %rax
jmp .LBB21_52
.LBB21_56:
.Ltmp641:
.Ltmp642:
.Ltmp643:
.Ltmp644:
movq 8(%rbx), %rax
movq 16(%rbx), %rdi
addq %rbx, %rdi
testb $1, %al
je .LBB21_58
movq (%rdi), %rcx
movq -1(%rax,%rcx), %rax
.LBB21_58:
movl $3900, %esi
xorl %edx, %edx
callq *%rax
jmp .LBB21_54
.LBB21_59:
.Ltmp419:
.Ltmp645:
.Ltmp646:
movq %rax, %rbx
.Ltmp420:
leaq -80(%rbp), %rdi
callq MutexTryLock::~MutexTryLock()@PLT
.Ltmp421:
.Ltmp647:
.Ltmp648:
.Ltmp649:
movq %rbx, %rdi
callq _unwind_resume_or_reth...@plt
.LBB21_61:
.Ltmp430:
.Ltmp650:
callq std::terminate()@PLT
.Ltmp651:
.Ltmp652:
> Build ATS with clang
> --------------------
>
> Key: TS-427
> URL: https://issues.apache.org/jira/browse/TS-427
> Project: Traffic Server
> Issue Type: Improvement
> Components: Build
> Affects Versions: 2.3.0
> Environment: OS: Any; Clang --version:
> clang version 1.1 (branches/release_27)
> Target: x86_64-pc-linux-gnu
> Thread model: posix
> Reporter: Igor Galić
> Attachments: ats-trunk.clang-trunk.patch, ats.clang.compile.patch,
> ats.clang.patch, ats.clang.patch, ats_clang_stuck.strace
>
>
> I've started compiling, and cleaning up traffic-server from trunk with clang,
> with this config:
> i.ga...@phoenix ~/Projects/asf/trafficserver (svn)-[trunk:989985] % cat
> config.notnice
> #! /bin/sh
> #
> # Created by configure
> CC="clang"; export CC
> CXX="clang"; export CXX
> CFLAGS="-fPIC -march=core2 -msse4.1 -D_FORTIFY_SOURCE=2"; export CFLAGS
> CXXFLAGS="-fPIC -march=core2 -msse4.1 -D_FORTIFY_SOURCE=2"; export CXXFLAGS
> LDFLAGS="-Wl,--as-needed -Wl,--warn-common"; export LDFLAGS
> "./configure" \
> "--enable-layout=opt" \
> "--with-user=proxy" \
> "--with-group=proxy" \
> "CC=clang" \
> "CFLAGS=-fPIC -march=core2 -msse4.1 -D_FORTIFY_SOURCE=2" \
> "LDFLAGS=-Wl,--as-needed" \
> "CXX=clang" \
> "$@"
> i.ga...@phoenix ~/Projects/asf/trafficserver (svn)-[trunk:989985] %
> Until I hit errors that seemed to include templates.
> I'm uploading the current patch for you to sanity-check and review. If it
> makes sense, I suppose it does a bit of a clean-up.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.