# Problem with Thread's memory (possible bug)

**URL:** <https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959>\
**Category:** Ruby\
**Created:** [November 7, 2006, 11:04am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959 "2006-11-07T11:04:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:04am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/1 "2006-11-07T11:04:16Z")

</div>

Hi all.

Some time ago I’ve started thread named “Memory crush somewhere in  
Socket”  
with no results. No I can describe the problem more correctly and in  
details.

First of all: Windows XP with ruby1.9, RUBY\_PLATFORM = i386-mswin32\_71

I have a window, and dispatch all keyboard events to Ruby’s block.  
All works good, except Ruby’s Threads. When I do anything like just  
Thread.new{} in my keyboard handling block, I have corrupted memory and  
entire program crashed soon.

How can I debug (or just walk around) this problem?

Thanks.

v.

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:04am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/2 "2006-11-07T11:04:35Z")

</div>

On Nov 5, 2006, at 11:02 AM, Victor Zverok S. wrote:

> Hi all.
> 
> Some time ago I’ve started thread named “Memory crush somewhere in  
> Socket”  
> with no results. No I can describe the problem more correctly and in  
> details.
> 
> First of all: Windows XP with ruby1.9, RUBY\_PLATFORM = i386-mswin32\_71

First of all, try to reproduce in Ruby 1.8.5.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:04am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/3 "2006-11-07T11:04:36Z")

</div>

From: Eric H. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Monday, November 06, 2006 12:41 AM

> First of all, try to reproduce in Ruby 1.8.5.

Unfortunately, I can’t do it easy.  
My window library extensively uses instance\_exec. Reproducing _without_  
this  
library would be a pain.

V.

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:05am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/4 "2006-11-07T11:05:54Z")

</div>

Hi,

In message “Re: Problem with Thread’s memory (possible bug)”  
on Mon, 6 Nov 2006 04:02:55 +0900, “Victor "Zverok" Shepelev”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|First of all: Windows XP with ruby1.9, RUBY\_PLATFORM = i386-mswin32\_71  
|  
|I have a window, and dispatch all keyboard events to Ruby’s block.  
|All works good, except Ruby’s Threads. When I do anything like just  
|Thread.new{} in my keyboard handling block, I have corrupted memory and  
|entire program crashed soon.  
|  
|How can I debug (or just walk around) this problem?

First, mere 1.9 does not mean anything. Specify the date.  
Full ruby -v line is better.

Besides that, is it possible to supply error reproducing code?

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:06am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/5 "2006-11-07T11:06:25Z")

</div>

Hi,

In message “Re: Problem with Thread’s memory (possible bug)”  
on Mon, 6 Nov 2006 19:15:33 +0900, “Victor "Zverok" Shepelev”  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|It was Ruby1.9-today, downloaded yesterday.  
|  
|ruby 1.9.0 (2006-11-04) [i386-mswin32\_71]

Much better.

|\>Besides that, is it possible to supply error reproducing code?  
|  
|Possible, but not very useful, as there is custom UI library used.

Hmm. Does you custom UI library tweaks system stack in any way? Ruby  
threads does evil things with setjmp/longjmp. They may not co-exist  
with other library with similar technique.

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:06am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/6 "2006-11-07T11:06:28Z")

</div>

Yukihiro M. (removed\_email\_address@domain.invalid)  
6/11/2006 15:39:43

> Much better.
> 
> |\>Besides that, is it possible to supply error reproducing code?  
> |  
> |Possible, but not very useful, as there is custom UI library used.
> 
> Hmm. Does you custom UI library tweaks system stack in any way? Ruby  
> threads does evil things with setjmp/longjmp. They may not co-exist  
> with other library with similar technique.

I don’t know definitely, because “my” library is really third-party  
closed-source DLL with my C/C++ wrapper. My wrapper does no evil, what  
about HTMLayout (third-party library), I’ll ask the author today or  
tomorrow and do the further investigation.

Thanks!

V.

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:06am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/7 "2006-11-07T11:06:02Z")

</div>

From: Yukihiro M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Monday, November 06, 2006 10:46 AM

> |  
> |How can I debug (or just walk around) this problem?
> 
> First, mere 1.9 does not mean anything. Specify the date.  
> Full ruby -v line is better.

Sorry ☹  
There was words “today’s version” in my platform description, but I’ve  
deleted them before send message.  
It was Ruby1.9-today, downloaded yesterday.

ruby 1.9.0 (2006-11-04) [i386-mswin32\_71]

> Besides that, is it possible to supply error reproducing code?

Possible, but not very useful, as there is custom UI library used.  
Here is it:

* * *

require ‘lib/config’

require ‘htmr’  
require ‘htmr/load’  
require ‘htmr/extend’  
require ‘htmr/events’

MAIN\_HTMR = File.join(HTMR\_PATH, ‘nanobrowser.htmr’)

win = Htmr::Window.create\_from\_file(MAIN\_HTMR, ‘NanoBrowser’)

Htmr::App::main\_window = win

include Htmr::Keys  
win.get(‘#url’).on\_key\_down(ENTER) do  
Thread.new{} #HERE’s thread usage!  
end

win.show

## Htmr::App::run

## inside ‘lib/config’ there is:

$:.unshift File.expand\_path(File.dirname( **FILE** ))  
$:.unshift File.expand\_path(File.join(File.dirname( **FILE** ),  
“vendors”))  
require ‘vendors’

DLL\_PATH = File.expand\_path(File.join(File.dirname( **FILE** ), ‘…’,  
‘bin’))

ENV[‘PATH’] += “;” + DLL\_PATH

## HTMR\_PATH = File.join(File.expand\_path(File.dirname( **FILE** )), ‘…’, ‘htmr’)

All htmr/\* files is UI library.

If I’ll comment “HERE’s thread” line, all works fine. I use my library  
till  
last 2 month inside rather complicated software, and there was almost no  
problems.

Thanks.

V.

---

<div class="post-metadata">

**Author:** ![Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f04885/32.png) [@Victor\_SZverokSS\_Sh](https://www.ruby-forum.com/u/Victor_SZverokSS_Sh)\
**Post date:** [November 7, 2006, 11:07am UTC](https://www.ruby-forum.com/t/problem-with-threads-memory-possible-bug/74959/8 "2006-11-07T11:07:43Z")

</div>

Yukihiro M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Monday, November 06, 2006 3:40 PM

> |\>Besides that, is it possible to supply error reproducing code?  
> |  
> |Possible, but not very useful, as there is custom UI library used.
> 
> Hmm. Does you custom UI library tweaks system stack in any way? Ruby  
> threads does evil things with setjmp/longjmp. They may not co-exist  
> with other library with similar technique.

Matz, there is no setjmp/longjmp or something like this in my UI  
library.  
I’d be grateful for any other advices, how to catch this.

V.
