New issue 2285: Segfault in vmprof sigprof_handler on OS X in release-5.1 https://bitbucket.org/pypy/pypy/issues/2285/segfault-in-vmprof-sigprof_handler-on-os-x
Nick Meharry: While evaluating PyPy for use on an existing project, I ran into a segfault. It appears to be the use of thread-locals in `sigprof_handler`. Specifically, on line 158 as a parameter to `get_stack_trace`, `get_vmprof_stack()` is called, which is just a wrapper around `RPY_THREADLOCALREF_GET(vmprof_tl_stack)`. This macro (at least on my machine) unwraps to this: ``` #!c ((struct pypy_threadlocal_s *)pthread_getspecific(pypy_threadlocal_key))->vmprof_tl_stack ``` According to the manual for `pthread_getspecific`, this function can return `NULL`. This concern is noted on line 118 within this file under the header "TERRIBLE HACK AHEAD". The calls to threadlocals on lines 130 (`pthread_self()`) and 131 (`get_current_thread_id()`) are guarded, but this one later on is not. My C is a little rusty, but I think this could be solved by returning `NULL` in `get_vmprof_stack()` if `_RPy_ThreadLocals_Get()` returns `NULL` and checking for that case in `sigprof_handler`. `get_vmprof_stack` doesn't appear to be used anywhere else. _______________________________________________ pypy-issue mailing list pypy-issue@python.org https://mail.python.org/mailman/listinfo/pypy-issue