Skip to content

Recursive call to mortal_getenv() causes deadlock #18341

Closed
@mhx

Description

@mhx

I've just built blead with a configuration that I've been building quite regularly back in the days:

./Configure -des -Uinstallusrbinperl -Dusethreads -DDEBUGGING=both -Doptimize=-ggdb3 -Dprefix=/home/mhx/perl/blead-mem -Dusedevel -Uversiononly -Aappend:ccflags="-DPERL_MEM_LOG -DPERL_MEM_LOG_STDERR -DPERL_MEM_LOG_ENV -DPERL_MEM_LOG_ENV_FD -DPERL_MEM_LOG_TIMESTAMP -DPERL_TRACK_MEMPOOL -DPERL_POISON -DDEBUG_LEAKING_SCALARS -DDEBUG_LEAKING_SCALARS_FORK_DUMP -DPERL_DEBUGGING_MSTATS -Wall -Wextra"

I'm pretty certain not all of this is needed for to reproduce the issue, but at least some of the MEM_LOG stuff is from a quick glance at the stack trace below.

The first time miniperl gets run during the build, it hangs immediately. Here's a stack trace:

(gdb) bt
#0  0x00007ffff7f8852b in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007ffff7f811e3 in pthread_mutex_lock () from /lib64/libpthread.so.0
#2  0x00005555557300d2 in Perl_mortal_getenv (str=0x555555b92fff "PERL_MEM_LOG") at inline.h:2608
#3  0x0000555555740882 in S_mem_log_common (mlt=MLT_NEW_SV, n=0, typesize=0, type_name=0x555555b919e8 "", sv=0x555555c89ea8, 
    oldalloc=0x0, newalloc=0x0, filename=0x555555ba2368 "sv.c", linenumber=9366, 
    funcname=0x555555bb5a58 <__FUNCTION__.24917> "Perl_newSVpv") at util.c:5011
#4  0x0000555555740fcc in Perl_mem_log_new_sv (sv=0x555555c89ea8, filename=0x555555ba2368 "sv.c", linenumber=9366, 
    funcname=0x555555bb5a58 <__FUNCTION__.24917> "Perl_newSVpv") at util.c:5150
#5  0x00005555557b40b5 in S_new_SV (my_perl=0x555555c862a0, file=0x555555ba2368 "sv.c", line=9366, 
    func=0x555555bb5a58 <__FUNCTION__.24917> "Perl_newSVpv") at sv.c:342
#6  0x00005555557fc810 in Perl_newSVpv (my_perl=0x555555c862a0, s=0x7fffffffe30e "en_US.UTF-8", len=0) at sv.c:9366
#7  0x000055555595709b in Perl_mortal_getenv (str=0x555555c44a27 "LANG") at inline.h:2613
#8  0x000055555595bab1 in Perl_init_i18nl10n (my_perl=0x555555c862a0, printwarn=1) at locale.c:3336
#9  0x00005555555d792d in perl_construct (my_perl=0x555555c862a0) at perl.c:430
#10 0x0000555555995871 in main (argc=1, argv=0x7fffffffdae8, env=0x7fffffffdaf8) at miniperlmain.c:111

I did a quick blame and reverted 24f3e84 and that fixed the deadlock. I didn't take a closer look yet, hopefully @khwilliamson has an idea :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions