Bug 220767 - lang/beignet: hangs if consumer is not linked against libpthread after jemalloc 5.0.0 update
Summary: lang/beignet: hangs if consumer is not linked against libpthread after jemall...
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-x11 (Nobody)
URL:
Keywords: needs-qa, regression
Depends on:
Blocks:
 
Reported: 2017-07-16 15:18 UTC by Jan Beich
Modified: 2020-04-02 18:20 UTC (History)
8 users (show)

See Also:
bugzilla: maintainer-feedback? (x11)
koobs: maintainer-feedback? (jasone)


Attachments
"bt full" output (11.70 KB, text/plain)
2017-07-16 15:26 UTC, Jan Beich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2017-07-16 15:18:53 UTC
After base r319971 some applications not already linked against threading library started to hang in [umtxn] state. It affects at least Beignet. However, bisecting jemalloc as part of libc requires 8 steps of rebasing FreeBSD-specific changes.

Maybe someone can suggest more apps to try that can trigger the issue.

$ pkg install clinfo beignet # requires bug 217635
$ LD_PRELOAD=/lib/libthr.so.3 clinfo # works fine
$ gdb clinfo
(gdb) r
Starting program: /usr/local/bin/clinfo
Number of platforms                               1
  Platform Name                                   Intel Gen OCL Driver
  Platform Vendor                                 Intel
  Platform Version                                OpenCL 2.0 beignet 1.3
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short cl_khr_gl_sharing
  Platform Extensions function suffix             Intel
[New LWP 102018 of process 60317]
^C
Thread 1 received signal SIGINT, Interrupt.
_umtx_op_err () at /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37
37      RSYSCALL_ERR(_umtx_op)
(gdb) bt
#0  _umtx_op_err () at /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37
#1  0x0000000803c579e4 in __thr_umutex_lock (mtx=0x803e7dc78 <_mutex_static_lock>, id=101914)
    at /usr/src/lib/libthr/thread/thr_umtx.c:80
#2  0x0000000803c61acc in _thr_umutex_lock (mtx=0x803e7dc78 <_mutex_static_lock>, id=101914)
    at /usr/src/lib/libthr/thread/thr_umtx.h:123
#3  0x0000000803c619b4 in init_static (thread=0x80068b000, mutex=0x801348e50)
    at /usr/src/lib/libthr/thread/thr_mutex.c:304
#4  0x0000000803c602f8 in check_and_init_mutex (mutex=0x801348e50, m=0x7fffffff2de0)
    at /usr/src/lib/libthr/thread/thr_mutex.c:598
#5  0x0000000803c5f689 in __pthread_mutex_trylock (mutex=0x801348e50)
    at /usr/src/lib/libthr/thread/thr_mutex.c:614
#6  0x0000000800d656b9 in malloc_mutex_trylock_final (mutex=0x801348e10)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/mutex.h:144
#7  0x0000000800d59602 in malloc_mutex_lock (tsdn=0x80063c088, mutex=0x801348e10)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/mutex.h:202
#8  0x0000000800d5b6b8 in __je_arena_tcache_fill_small (tsdn=0x80063c088, arena=0x801344980,
    tcache=0x80063c240, tbin=0x80063c2e0, binind=6, prof_accumbytes=0) at jemalloc_arena.c:1433
#9  0x0000000800cd7013 in __je_tcache_alloc_small_hard (tsdn=0x80063c088, arena=0x801344980,
    tcache=0x80063c240, tbin=0x80063c2e0, binind=6, tcache_success=0x7fffffff53f6)
    at jemalloc_tcache.c:93
#10 0x0000000800d8ea3e in tcache_alloc_small (tsd=0x80063c088, arena=0x801344980,
    tcache=0x80063c240, size=96, binind=6, zero=true, slow_path=false)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/tcache_inlines.h:86
#11 arena_malloc (tsdn=0x80063c088, arena=0x0, size=96, ind=6, zero=true, tcache=0x80063c240,
    slow_path=false) at /usr/src/contrib/jemalloc/include/jemalloc/internal/arena_inlines_b.h:101
#12 iallocztm (tsdn=0x80063c088, size=96, ind=6, zero=true, tcache=0x80063c240, is_internal=false,
    arena=0x0, slow_path=false)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_inlines_c.h:33
#13 imalloc_no_sample (sopts=0x7fffffff5300, dopts=0x7fffffff52d0, tsd=0x80063c088, size=96,
    usize=96, ind=6) at jemalloc_jemalloc.c:1654
#14 imalloc_body (sopts=0x7fffffff5300, dopts=0x7fffffff52d0, tsd=0x80063c088)
    at jemalloc_jemalloc.c:1850
#15 imalloc (sopts=0x7fffffff5300, dopts=0x7fffffff52d0) at jemalloc_jemalloc.c:1950
#16 __calloc (num=1, size=96) at jemalloc_jemalloc.c:2064
#17 0x0000000803c5fc0e in mutex_init (mutex=0x801348e50,
    mutex_attr=0x803e72758 <_pthread_mutexattr_default>, calloc_cb=0x800d8bea0 <__calloc>)
    at /usr/src/lib/libthr/thread/thr_mutex.c:292
#18 0x0000000803c619dc in init_static (thread=0x80068b000, mutex=0x801348e50)
    at /usr/src/lib/libthr/thread/thr_mutex.c:307
#19 0x0000000803c602f8 in check_and_init_mutex (mutex=0x801348e50, m=0x7fffffff60d0)
    at /usr/src/lib/libthr/thread/thr_mutex.c:598
#20 0x0000000803c5f689 in __pthread_mutex_trylock (mutex=0x801348e50)
    at /usr/src/lib/libthr/thread/thr_mutex.c:614
#21 0x0000000800d656b9 in malloc_mutex_trylock_final (mutex=0x801348e10)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/mutex.h:144
#22 0x0000000800d59602 in malloc_mutex_lock (tsdn=0x80063c088, mutex=0x801348e10)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/mutex.h:202
#23 0x0000000800d5b6b8 in __je_arena_tcache_fill_small (tsdn=0x80063c088, arena=0x801344980,
    tcache=0x80063c240, tbin=0x80063c2e0, binind=6, prof_accumbytes=0) at jemalloc_arena.c:1433
#24 0x0000000800cd7013 in __je_tcache_alloc_small_hard (tsdn=0x80063c088, arena=0x801344980,
    tcache=0x80063c240, tbin=0x80063c2e0, binind=6, tcache_success=0x7fffffff86d6)
    at jemalloc_tcache.c:93
#25 0x0000000800d72886 in tcache_alloc_small (tsd=0x80063c088, arena=0x801344980,
    tcache=0x80063c240, size=88, binind=6, zero=false, slow_path=false)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/tcache_inlines.h:86
#26 arena_malloc (tsdn=0x80063c088, arena=0x0, size=88, ind=6, zero=false, tcache=0x80063c240,
    slow_path=false) at /usr/src/contrib/jemalloc/include/jemalloc/internal/arena_inlines_b.h:101
#27 iallocztm (tsdn=0x80063c088, size=88, ind=6, zero=false, tcache=0x80063c240, is_internal=false,
    arena=0x0, slow_path=false)
    at /usr/src/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal_inlines_c.h:33
#28 imalloc_no_sample (sopts=0x7fffffff85e0, dopts=0x7fffffff85b0, tsd=0x80063c088, size=88,
    usize=96, ind=6) at jemalloc_jemalloc.c:1654
#29 imalloc_body (sopts=0x7fffffff85e0, dopts=0x7fffffff85b0, tsd=0x80063c088)
    at jemalloc_jemalloc.c:1850
#30 imalloc (sopts=0x7fffffff85e0, dopts=0x7fffffff85b0) at jemalloc_jemalloc.c:1950
#31 __malloc (size=88) at jemalloc_jemalloc.c:1981
#32 0x00000008033b81a8 in operator new (size=88) at /usr/src/contrib/libc++/src/new.cpp:70
#33 0x000000080803aa89 in llvm::User::operator new(unsigned long, unsigned int) ()
   from /usr/local/lib/beignet//libgbe.so
#34 0x0000000806ea6b34 in clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) () from /usr/local/lib/beignet//libgbe.so
#35 0x0000000806ea8551 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () from /usr/local/lib/beignet//libgbe.so
#36 0x0000000806eba8d9 in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /usr/local/lib/beignet//libgbe.so
#37 0x0000000806eb6774 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /usr/local/lib/beignet//libgbe.so
#38 0x0000000806ebc322 in clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) ()
   from /usr/local/lib/beignet//libgbe.so
#39 0x0000000806e3c82f in (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) () from /usr/local/lib/beignet//libgbe.so
#40 0x0000000806e2fb85 in clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) ()
   from /usr/local/lib/beignet//libgbe.so
#41 0x00000008077d0462 in clang::ParseAST(clang::Sema&, bool, bool) ()
   from /usr/local/lib/beignet//libgbe.so
#42 0x0000000806bdc2b9 in clang::FrontendAction::Execute() () from /usr/local/lib/beignet//libgbe.so
#43 0x0000000806ba2cf1 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
   from /usr/local/lib/beignet//libgbe.so
 std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, unsigned long, char*, unsigned long*, unsigned int) () from /usr/local/lib/beignet//libgbe.so
#45 0x00000008067848b3 in gbe::programNewFromSource(unsigned int, char const*, unsigned long, char const*, char*, unsigned long*) () from /usr/local/lib/beignet//libgbe.so
#46 0x00000008019617c7 in cl_program_build (p=0x8006cd1c0, options=0x801992f4d "")
    at src/cl_program.c:626
#47 0x0000000801952782 in clBuildProgram (program=0x8006cd1c0, num_devices=1,
    device_list=0x7fffffffe050, options=0x801992f4d "", pfn_notify=0x0, user_data=0x0)
    at src/cl_api.c:835
#48 0x00000008019757b4 in cl_self_test (device=0x801bcf2a0 <intel_skl_gt2_device>,
    atomic_in_l3_flag=SELF_TEST_PASS) at src/cl_device_id.c:856
#49 0x0000000801975a3e in cl_get_device_ids (platform=0x801bcb3d8 <intel_platform_data>,
    device_type=4294967295, num_entries=0, devices=0x0, num_devices=0x8007e8cf0)
    at src/cl_device_id.c:911
#50 0x00000008019554b3 in clGetDeviceIDs (platform=0x801bcb3d8 <intel_platform_data>,
    device_type=4294967295, num_entries=0, devices=0x0, num_devices=0x8007e8cf0)
    at src/cl_api_device_id.c:43
#51 0x000000080083e065 in clGetDeviceIDs (platform=0x801bcb3d8 <intel_platform_data>,
    device_type=4294967295, num_entries=0, devices=0x0, num_devices=0x8007e8cf0)
    at ocl_icd_loader_gen.c:58
#52 0x0000000000402341 in printPlatformInfo (p=0) at src/clinfo.c:459
#53 0x000000000040a3bd in main (argc=1, argv=0x7fffffffe2b8) at src/clinfo.c:2676
Comment 1 Jan Beich freebsd_committer 2017-07-16 15:26:18 UTC
Created attachment 184402 [details]
"bt full" output
Comment 2 Alexey Dokuchaev freebsd_committer 2018-01-22 06:51:50 UTC
The same thing happens with `games/quake2lnx'.  Similarly, if I link it explicitly against libpthread or run it as ``env LD_PRELOAD=/lib/libthr.so.3 quake2 ...'' it starts normally.

I'm reluctant to make changes to the port though before we know what particular change in jemalloc is breaking previously working code (ports), and if that code just worked by accident, or the bug had sneaked into jemalloc 5.0.0.
Comment 3 Alexey Dokuchaev freebsd_committer 2018-01-22 14:09:23 UTC
Last two comments in https://github.com/jemalloc/jemalloc/issues/907 (October 10th-ish) might or might not be related.
Comment 4 Jan Beich freebsd_committer 2018-01-23 05:03:17 UTC
Do we have tests for base r276630? For one, jemalloc 5.0.0 changed

  bool
  malloc_mutex_first_thread(void)
  {

  #ifdef JEMALLOC_MUTEX_INIT_CB
	  postpone_init = false;
	  while (postponed_mutexes != NULL) {
		  if (_pthread_mutex_init_calloc_cb(&postponed_mutexes->lock,
		      bootstrap_calloc) != 0)
			  return (true);
		  postponed_mutexes = postponed_mutexes->postponed_next;
	  }
  #endif
	  return (false);
  }

into

  bool
  malloc_mutex_first_thread(void) {

  #ifndef JEMALLOC_MUTEX_INIT_CB
	  return (malloc_mutex_first_thread());
  #else
	  return (false);
  #endif
  }
Comment 5 Alexey Dokuchaev freebsd_committer 2018-01-23 09:55:50 UTC
(In reply to Jan Beich from comment #4)

FWIW, I've tried to play with malloc_mutex_first_thread() implementation, JEMALLOC_MUTEX_INIT_CB (+ some related macros), using different atomics implementation in jemalloc 5.0.0, all without any luck.

For the record, I'm including this advice from John Baldwin:
> I wonder if it is tripping over pthread_once not working in libc.  The stub
> for pthread_once in libc is a nop and has been for a long time.  I added
> a functioning stub (called _libc_once) to libc for it's internal use (there
> is a _once() wrapper that will call _pthread_once when using libpthread and
> _libc_once otherwise).  It might be interesting to build jemalloc with
> '-Dpthread_once=_once' to see if that makes a difference?
I've tried this as well and it did not help.
Comment 6 Jason Evans freebsd_committer 2018-05-11 18:44:03 UTC
I don't have any specific ideas as to why this is happening.  Bootstrapping jemalloc on FreeBSD is really tricky, because pthreads mutexes use malloc, and jemalloc has to jump through hoops to initialize its mutexes in multiple phases.

It looks like beignet depends on the libpthread-stubs package.  Is it possible that the stubs don't sufficiently stub out the libc-internal hooks that jemalloc uses to bootstrap?  Here's a list of pthreads-related symbols jemalloc depends on (generated by building stand-alone jemalloc):

_pthread_mutex_init_calloc_cb
je_pthread_create_wrapper
pthread_cond_init
pthread_cond_signal
pthread_cond_timedwait
pthread_cond_wait
pthread_create
pthread_create_fptr
pthread_join
pthread_mutex_lock
pthread_mutex_trylock
pthread_mutex_unlock
pthread_sigmask
Comment 7 Jan Beich freebsd_committer 2018-05-13 05:46:04 UTC
(In reply to Jason Evans from comment #6)
Some facts:
- libpthread-stubs is an alias to -pthread since ports r437182
- beignet doesn't use libpthread-stubs
- mesa-libs uses libpthread-stubs
- beignet optionally uses mesa-libs for cl_khr_gl_sharing
- libcl (from beignet) is already linked against libpthread
- ocl-icd uses dlopen() to pull libcl
- clinfo isn't linked against libpthread

After disabling beignet -> mesa-libs dependency clinfo crashes if not passed  LD_PRELOAD=/lib/libthr.so.3:

$ clinfo
Number of platforms                               1
  Platform Name                                   Intel Gen OCL Driver
  Platform Vendor                                 Intel
  Platform Version                                OpenCL 2.0 beignet 1.3
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_spir cl_khr_icd cl_intel_accelerator cl_intel_subgroups cl_intel_subgroups_short
  Platform Extensions function suffix             Intel
[New LWP 101911 of process 86314]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x0000000802463650 in clang::CodeGen::LValue::MakeAddr(clang::CodeGen::Address, clang::QualType, clang::ASTContext&, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo) () from /usr/local/lib/beignet//libgbe.so
(gdb) backtrace
#0  0x0000000802463650 in clang::CodeGen::LValue::MakeAddr(clang::CodeGen::Address, clang::QualType, clang::ASTContext&, clang::CodeGen::LValueBaseInfo, clang::CodeGen::TBAAAccessInfo) () from /usr/local/lib/beignet//libgbe.so
#1  0x0000000802482287 in clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) ()
   from /usr/local/lib/beignet//libgbe.so
#2  0x0000000802477b79 in clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) ()
   from /usr/local/lib/beignet//libgbe.so
#3  0x000000080247fc13 in clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) () from /usr/local/lib/beignet//libgbe.so
#4  0x0000000802519c36 in clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) () from /usr/local/lib/beignet//libgbe.so
#5  0x00000008025205fa in (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) ()
   from /usr/local/lib/beignet//libgbe.so
#6  0x0000000802510258 in clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) ()
   from /usr/local/lib/beignet//libgbe.so
#7  0x000000080247f015 in clang::CodeGen::CodeGenFunction::EmitPointerWithAlignment(clang::Expr const*, clang::CodeGen::LValueBaseInfo*, clang::CodeGen::TBAAAccessInfo*) () from /usr/local/lib/beignet//libgbe.so
#8  0x0000000802480352 in clang::CodeGen::CodeGenFunction::EmitArraySubscriptExpr(clang::ArraySubscriptExpr const*, bool) () from /usr/local/lib/beignet//libgbe.so
#9  0x0000000802477c51 in clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) ()
   from /usr/local/lib/beignet//libgbe.so
#10 0x000000080247fc13 in clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) () from /usr/local/lib/beignet//libgbe.so
#11 0x0000000802519c36 in clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) () from /usr/local/lib/beignet//libgbe.so
#12 0x00000008025205fa in (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) ()
   from /usr/local/lib/beignet//libgbe.so
#13 0x0000000802515f57 in clang::StmtVisitorBase<clang::make_ptr, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) () from /usr/local/lib/beignet//libgbe.so
#14 0x0000000802510258 in clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) ()
   from /usr/local/lib/beignet//libgbe.so
#15 0x0000000802477572 in clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) () from /usr/local/lib/beignet//libgbe.so
#16 0x0000000802477524 in clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) ()
   from /usr/local/lib/beignet//libgbe.so
#17 0x00000008024c07b1 in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) () from /usr/local/lib/beignet//libgbe.so
#18 0x00000008024c933f in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () from /usr/local/lib/beignet//libgbe.so
#19 0x00000008026085d5 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () from /usr/local/lib/beignet//libgbe.so
#20 0x000000080261db9c in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /usr/local/lib/beignet//libgbe.so
#21 0x0000000802617c64 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /usr/local/lib/beignet//libgbe.so
#22 0x0000000802620852 in clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) ()
   from /usr/local/lib/beignet//libgbe.so
#23 0x00000008026f1d3f in (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ()
   from /usr/local/lib/beignet//libgbe.so
#24 0x000000080243956a in clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) ()
   from /usr/local/lib/beignet//libgbe.so
#25 0x000000080303ac22 in clang::ParseAST(clang::Sema&, bool, bool) () from /usr/local/lib/beignet//libgbe.so
#26 0x000000080212f969 in clang::FrontendAction::Execute() () from /usr/local/lib/beignet//libgbe.so
#27 0x00000008020e6ec1 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
   from /usr/local/lib/beignet//libgbe.so
#28 0x0000000801c84381 in gbe::buildModuleFromSource (
    source=0x8013392a0 "__kernel void self_test(__global int *buf) {  __local int tmp[3];  tmp[get_local_id(0)] = buf[get_local_id(0)];  barrier(CLK_LOCAL_MEM_FENCE);  buf[get_global_id(0)] = tmp[2 - get_local_id(0)] + buf[g"..., out_module=0x7fffffffda70, llvm_ctx=0x800257440, dumpLLVMFileName=..., dumpSPIRBinaryName=..., options=...,
    stringSize=1048576, err=0x8078435c0 "", errSize=0x801339288, oclVersion=120)
    at backend/src/backend/program.cpp:735
#29 0x0000000801c7035d in gbe::programNewFromSource (deviceID=6418,
    source=0x8013392a0 "__kernel void self_test(__global int *buf) {  __local int tmp[3];  tmp[get_local_id(0)] = buf[get_local_id(0)];  barrier(CLK_LOCAL_MEM_FENCE);  buf[get_global_id(0)] = tmp[2 - get_local_id(0)] + buf[g"..., stringSize=1048576, options=0x8008addaa "", err=0x8078435c0 "", errSize=0x801339288)
    at backend/src/backend/program.cpp:1058
#30 0x00000008008d2b77 in cl_program_build (p=0x8013391c0, options=0x8008addaa "") at src/cl_program.c:597
#31 0x00000008008c2cdd in clBuildProgram (program=0x8013391c0, num_devices=1, device_list=0x7fffffffe040,
    options=0x8008addaa "", pfn_notify=0x0, user_data=0x0) at src/cl_api.c:835
#32 0x00000008008e85d4 in cl_self_test (device=0x800945218 <intel_skl_gt2_device>,
    atomic_in_l3_flag=SELF_TEST_PASS) at src/cl_device_id.c:900
#33 0x00000008008e885e in cl_get_device_ids (platform=0x800941238 <intel_platform_data>, device_type=4294967295,
    num_entries=0, devices=0x0, num_devices=0x8033dbeb0) at src/cl_device_id.c:955
#34 0x00000008008c6093 in clGetDeviceIDs (platform=0x800941238 <intel_platform_data>, device_type=4294967295,
    num_entries=0, devices=0x0, num_devices=0x8033dbeb0) at src/cl_api_device_id.c:43
#35 0x000000080025fada in clGetDeviceIDs_hid () from /usr/local/lib/libOpenCL.so.1
#36 0x0000000000207071 in printPlatformInfo (p=0) at src/clinfo.c:459
#37 0x000000000020f0ed in main (argc=1, argv=0x7fffffffe278) at src/clinfo.c:2676

Sorry, I didn't build devel/llvm* with debug symbols this time.
Comment 8 Jan Beich freebsd_committer 2018-05-13 06:03:33 UTC
dlopen'ing libpthread should be supported since base r276630.
Comment 9 Alexey Dokuchaev freebsd_committer 2018-05-20 17:25:06 UTC
I've just tested Quake 2 again after jemalloc update to version 5.1.0 as per base r333477, it is still broken. :-(
Comment 10 Alexey Dokuchaev freebsd_committer 2018-06-04 17:04:30 UTC
(In reply to Jason Evans from comment #6)
> I don't have any specific ideas as to why this is happening.  Bootstrapping
> jemalloc on FreeBSD is really tricky, because pthreads mutexes use malloc,
> and jemalloc has to jump through hoops to initialize its mutexes in multiple
> phases [...]
OK, but can you think of anything that had *changed* between 5.0.0 vs 4.5.0 in that area that could've caused this regression?  Looks like some software was working fine for years (that is the case at least for Quake2) until 5.0.0 hit the tree, so I want to know if 5.0.0 had revealed a bug in those programs, or rather introduced a bug into itself?
Comment 11 Alexey Dokuchaev freebsd_committer 2019-01-30 11:59:51 UTC
It very much looks like base r343566 might finally fix this.  On the latest -CURRENT, Quake II starts normally again.
Comment 12 Jan Beich freebsd_committer 2019-01-30 15:30:45 UTC
I confirm. beignet issue is masked (see below) after ports r473868, so I had to downgrade the port before testing base r343566.

$ ldd -a =clinfo
/usr/local/bin/clinfo:
        libOpenCL.so.1 => /usr/local/lib/libOpenCL.so.1 (0x800259000)
        libc.so.7 => /lib/libc.so.7 (0x800276000)
/usr/local/lib/libOpenCL.so.1:
        libdl.so.1 => /usr/lib/libdl.so.1 (0x800697000)
        libthr.so.3 => /lib/libthr.so.3 (0x80069b000)  <--- LOOK HERE
        libc.so.7 => /lib/libc.so.7 (0x800276000)
/usr/lib/libdl.so.1:
        libc.so.7 => /lib/libc.so.7 (0x800276000)
/lib/libthr.so.3:
        libc.so.7 => /lib/libc.so.7 (0x800276000)
Comment 13 Rene Ladan freebsd_committer 2020-04-02 18:20:48 UTC
lang/beignet expired today and has been removed.