[ruby-core:63102] [ruby-trunk - Bug #9884] [Closed] thread_pthread.c assumes pthread_t is a scalar type

From: nobu@...
Date: 2014-06-11 08:38:18 UTC
List: ruby-core #63102
Issue #9884 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r46406.

----------
thread.c: fix for non-scalar pthread_t

* configure.in (rb_cv_scalar_pthread_t): pthread_t is not required
  to be a scalar type.
* thread.c (fill_thread_id_string, thread_id_str): dump pthread_t
  in hexadecimal form if it is not a scalar type, assume it can be
  represented in a pointer form otherwise.  based on the patch by
  Rei Odaira at [ruby-core:62867].  [ruby-core:62857] [Bug #9884]
* thread_pthread.c (Init_native_thread, thread_start_func_1),
  (native_thread_create): set thread_id_str if needed.
* vm_core.h (rb_thread_t): add thread_id_string if needed.

----------------------------------------
Bug #9884: thread_pthread.c assumes pthread_t is a scalar type
https://bugs.ruby-lang.org/issues/9884#change-47168

* Author: Rei Odaira
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0dev (2014-05-30 trunk 46238) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Many code lines in `thread_pthread.c` assume `pthread_t` is a scalar type. For example,

~~~
    thread_debug("ubf_select_each (%p)\n", (void *)th->thread_id);
~~~

and

~~~
    if (!timer_thread_id) {
~~~

I don't think the standard guarantees `pthread_t` is a scalar type.  z/OS defines `pthread_t` as a struct, and there seem to be other such environments.
https://sourceware.org/pthreads-win32/faq.html

I understand it could be too cumbersome to rewrite the source, assuming `pthread_t` might not be a scalar, and actually I am not sure what would be the best way to rewrite it, but I appreciate it if you guys could think of it for the maximum portability. If needed, I am willing to list the source lines to be rewritten.

---Files--------------------------------
opaque_thread_id.patch (7.63 KB)


-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next