ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:87345] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
       [not found] <redmine.issue-14807.20180601205127@ruby-lang.org>
@ 2018-06-01 20:51 ` merch-redmine
  2018-06-01 22:03   ` [ruby-core:87346] " Eric Wong
  2018-06-01 22:23 ` [ruby-core:87347] " merch-redmine
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: merch-redmine @ 2018-06-01 20:51 UTC (permalink / raw)
  To: ruby-core

Issue #14807 has been reported by jeremyevans0 (Jeremy Evans).

----------------------------------------
Bug #14807: 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
https://bugs.ruby-lang.org/issues/14807

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* Assignee: normalperson (Eric Wong)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-06-01 trunk 63545) [x86_64-openbsd]
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONTNEED
----------------------------------------
r63238 refactored thread_pthread.c, and where there was previously a pthread_condattr_init call to initialize the pthread_condattr_t value, it removed the call and passed the pthread_condattr_t* directly to pthread_condattr_setclock without initializing the value by calling pthread_condattr_init first.  On some operating systems that works, but it's not required to work, and it segfaults on OpenBSD because the pthread_condattr_t is not initialized.

The attached patch should fix the problem.

---Files--------------------------------
0001-Initialize-condattr_monotonic-via-pthread_condattr_i.patch (1.08 KB)


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:87346] Re: [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
  2018-06-01 20:51 ` [ruby-core:87345] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call merch-redmine
@ 2018-06-01 22:03   ` Eric Wong
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2018-06-01 22:03 UTC (permalink / raw)
  To: ruby-core

Thanks, r63548

Btw, is PTHREAD_COND_INITIALIZER supported on OpenBSD?

Something like this:
```
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -55,7 +55,7 @@ static struct {
 #if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && \
     defined(CLOCK_REALTIME) && defined(CLOCK_MONOTONIC) && \
     defined(HAVE_CLOCK_GETTIME)
-static pthread_condattr_t condattr_mono;
+static pthread_condattr_t condattr_mono = PTHREAD_COND_INITIALIZER;
 static pthread_condattr_t *condattr_monotonic = &condattr_mono;
 #else
 static const void *const condattr_monotonic = NULL;
```

...And reverting your patch.  Should save a few instructions at
startup since it avoids linkage and function call at startup.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:87347] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
       [not found] <redmine.issue-14807.20180601205127@ruby-lang.org>
  2018-06-01 20:51 ` [ruby-core:87345] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call merch-redmine
@ 2018-06-01 22:23 ` merch-redmine
  2018-09-22 18:08 ` [ruby-core:89128] " taca
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: merch-redmine @ 2018-06-01 22:23 UTC (permalink / raw)
  To: ruby-core

Issue #14807 has been updated by jeremyevans0 (Jeremy Evans).


normalperson (Eric Wong) wrote:
>  Btw, is PTHREAD_COND_INITIALIZER supported on OpenBSD?

It's defined but I don't think it would be usable:

~~~
/usr/include/pthread.h:#define PTHREAD_COND_INITIALIZER NULL
~~~

----------------------------------------
Bug #14807: 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
https://bugs.ruby-lang.org/issues/14807#change-72336

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* Assignee: normalperson (Eric Wong)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-06-01 trunk 63545) [x86_64-openbsd]
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONTNEED
----------------------------------------
r63238 refactored thread_pthread.c, and where there was previously a pthread_condattr_init call to initialize the pthread_condattr_t value, it removed the call and passed the pthread_condattr_t* directly to pthread_condattr_setclock without initializing the value by calling pthread_condattr_init first.  On some operating systems that works, but it's not required to work, and it segfaults on OpenBSD because the pthread_condattr_t is not initialized.

The attached patch should fix the problem.

---Files--------------------------------
0001-Initialize-condattr_monotonic-via-pthread_condattr_i.patch (1.08 KB)


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:89135] Re: [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
  2018-09-22 18:08 ` [ruby-core:89128] " taca
@ 2018-09-21  9:32   ` Eric Wong
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Wong @ 2018-09-21  9:32 UTC (permalink / raw)
  To: ruby-core

> https://bugs.ruby-lang.org/issues/14807#change-74146

Right, already in trunk at r63548

And back to Jeremy's earlier comment:
> It's defined but I don't think it would be usable:
> 
> /usr/include/pthread.h:#define PTHREAD_COND_INITIALIZER NULL

Without reading the OpenBSD pthreads library source code;
I suspect that it would be usable.

The condvar implementation can safely perform lazy-initialization
because it can rely on the underlying mutex for protection.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:89128] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
       [not found] <redmine.issue-14807.20180601205127@ruby-lang.org>
  2018-06-01 20:51 ` [ruby-core:87345] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call merch-redmine
  2018-06-01 22:23 ` [ruby-core:87347] " merch-redmine
@ 2018-09-22 18:08 ` taca
  2018-09-21  9:32   ` [ruby-core:89135] " Eric Wong
  2018-09-29 15:54 ` [ruby-core:89216] " taca
  2019-05-25  0:59 ` [ruby-core:92835] " merch-redmine
  4 siblings, 1 reply; 7+ messages in thread
From: taca @ 2018-09-22 18:08 UTC (permalink / raw)
  To: ruby-core

Issue #14807 has been updated by taca (Takahiro Kambe).


Hi,

The similar problem occurs on NetBSD 8.0_STABLE.  (And I belive it would be occur on 7.2.)

`PTHREAD_COND_INITIALIZER` is for `pthread_cond_t` not for `pthread_condattr_t`.
So, initializing `condattr_mono` (via `condattr_monotonic`) with `pthread_condattr_init()` is correct way to fix the problem as the attached patch.

Best regards.

----------------------------------------
Bug #14807: 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
https://bugs.ruby-lang.org/issues/14807#change-74146

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* Assignee: normalperson (Eric Wong)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-06-01 trunk 63545) [x86_64-openbsd]
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONTNEED
----------------------------------------
r63238 refactored thread_pthread.c, and where there was previously a pthread_condattr_init call to initialize the pthread_condattr_t value, it removed the call and passed the pthread_condattr_t* directly to pthread_condattr_setclock without initializing the value by calling pthread_condattr_init first.  On some operating systems that works, but it's not required to work, and it segfaults on OpenBSD because the pthread_condattr_t is not initialized.

The attached patch should fix the problem.

---Files--------------------------------
0001-Initialize-condattr_monotonic-via-pthread_condattr_i.patch (1.08 KB)


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:89216] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
       [not found] <redmine.issue-14807.20180601205127@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2018-09-22 18:08 ` [ruby-core:89128] " taca
@ 2018-09-29 15:54 ` taca
  2019-05-25  0:59 ` [ruby-core:92835] " merch-redmine
  4 siblings, 0 replies; 7+ messages in thread
From: taca @ 2018-09-29 15:54 UTC (permalink / raw)
  To: ruby-core

Issue #14807 has been updated by taca (Takahiro Kambe).


Hi,

Wheather `PTHREAD_COND_INITIALIZER` is work on OpenBSD or not, it should be used for initialize `pthread_cond_t` variable and
it should not be used for initialize `pthread_condattr_t` variable since they are diffrernet type and it cause compile error no NetBSD.



----------------------------------------
Bug #14807: 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
https://bugs.ruby-lang.org/issues/14807#change-74243

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* Assignee: normalperson (Eric Wong)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-06-01 trunk 63545) [x86_64-openbsd]
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONTNEED
----------------------------------------
r63238 refactored thread_pthread.c, and where there was previously a pthread_condattr_init call to initialize the pthread_condattr_t value, it removed the call and passed the pthread_condattr_t* directly to pthread_condattr_setclock without initializing the value by calling pthread_condattr_init first.  On some operating systems that works, but it's not required to work, and it segfaults on OpenBSD because the pthread_condattr_t is not initialized.

The attached patch should fix the problem.

---Files--------------------------------
0001-Initialize-condattr_monotonic-via-pthread_condattr_i.patch (1.08 KB)


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:92835] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
       [not found] <redmine.issue-14807.20180601205127@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2018-09-29 15:54 ` [ruby-core:89216] " taca
@ 2019-05-25  0:59 ` merch-redmine
  4 siblings, 0 replies; 7+ messages in thread
From: merch-redmine @ 2019-05-25  0:59 UTC (permalink / raw)
  To: ruby-core

Issue #14807 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

Fixed by commit:832b601e49fd402ec7f30b36a95473131e93ae94.  As taca explained, PTHREAD_COND_INITIALIZER should not be used for pthread_condattr_t.

----------------------------------------
Bug #14807: 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call
https://bugs.ruby-lang.org/issues/14807#change-78214

* Author: jeremyevans0 (Jeremy Evans)
* Status: Closed
* Priority: Normal
* Assignee: normalperson (Eric Wong)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-06-01 trunk 63545) [x86_64-openbsd]
* Backport: 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONTNEED
----------------------------------------
r63238 refactored thread_pthread.c, and where there was previously a pthread_condattr_init call to initialize the pthread_condattr_t value, it removed the call and passed the pthread_condattr_t* directly to pthread_condattr_setclock without initializing the value by calling pthread_condattr_init first.  On some operating systems that works, but it's not required to work, and it segfaults on OpenBSD because the pthread_condattr_t is not initialized.

The attached patch should fix the problem.

---Files--------------------------------
0001-Initialize-condattr_monotonic-via-pthread_condattr_i.patch (1.08 KB)


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-05-25  0:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-14807.20180601205127@ruby-lang.org>
2018-06-01 20:51 ` [ruby-core:87345] [Ruby trunk Bug#14807] 2.6.0-preview2 segfaults on OpenBSD due to missing pthread_condattr_init call merch-redmine
2018-06-01 22:03   ` [ruby-core:87346] " Eric Wong
2018-06-01 22:23 ` [ruby-core:87347] " merch-redmine
2018-09-22 18:08 ` [ruby-core:89128] " taca
2018-09-21  9:32   ` [ruby-core:89135] " Eric Wong
2018-09-29 15:54 ` [ruby-core:89216] " taca
2019-05-25  0:59 ` [ruby-core:92835] " merch-redmine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).