# Ruby crashes on windows across three versions

**URL:** <https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381>\
**Category:** Ruby\
**Created:** [April 18, 2007, 9:45pm UTC](https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381 "2007-04-18T21:45:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [April 18, 2007, 9:45pm UTC](https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381/1 "2007-04-18T21:45:56Z")

</div>

I’m working on some scripts for work to manage some build releases,  
and I’m using ruby and the p4ruby libraries on Windows XP. When I  
run my script from the command line or by loading it into IRB, I get:

* * *

./SourceControl.rb:63: [BUG] Segmentation fault  
ruby 1.8.2 (2004-12-25) [i386-mswin32]

## This application has requested the Runtime to terminate it in an unusual way. Please contact the application’s support team for more information.

I’ve tried with ruby 1.8.2, 1.8.5, 1.8.6 (all installed w/ the One-  
click installer), and I get the exact same thing with each of them.  
Just to see if I could get a better error message, I downloaded  
ArachnoRuby and ran w/ that. My script runs successfully when I run  
it from the IDE. While that has suddenly sold me on ArachnoRuby, it  
doesn’t clear up my problem. Any thoughts?

Thanks,  
Ben

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [April 18, 2007, 10:01pm UTC](https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381/2 "2007-04-18T22:01:58Z")

</div>

On 4/18/07, Ben [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## unusual way. Please contact the application’s support team for more information.
> 
> I’ve tried with ruby 1.8.2, 1.8.5, 1.8.6 (all installed w/ the One-  
> click installer), and I get the exact same thing with each of them.  
> Just to see if I could get a better error message, I downloaded  
> ArachnoRuby and ran w/ that. My script runs successfully when I run  
> it from the IDE. While that has suddenly sold me on ArachnoRuby, it  
> doesn’t clear up my problem. Any thoughts?

I’m sure it would help if you posted the code causing the error. The  
first guess would be that there’s a bug or incompatibility in the  
p4ruby extension.

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [April 18, 2007, 10:09pm UTC](https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381/3 "2007-04-18T22:09:59Z")

</div>

On 4/18/07, Ben [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> unusual way.  
> Please contact the application’s support team for more information.

Is line 63 of SourceControl.rb a call into the p4ruby API’s? If so,  
then you need to open a bug with the p4ruby developer(s). Since  
p4ruby is a ruby C extension, the error most likely lies there.

Blessings,  
TwP

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [April 18, 2007, 10:36pm UTC](https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381/4 "2007-04-18T22:36:02Z")

</div>

On Apr 18, 4:09 pm, “Tim P.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is line 63 of SourceControl.rb a call into the p4ruby API’s? If so,  
> then you need to open a bug with the p4ruby developer(s). Since  
> p4ruby is a ruby C extension, the error most likely lies there.

Unfortunately no. I’ll post the code (to my eternal  
embarrassment). I hate posting code to usenet groups. You get  
everything questioned from your variable names to your personal  
lineage. 🙂 My qualifiers - this is my quick and dirty parser to get  
something going and I’m still learning ruby. Please be kind to  
me. 🙂

## The parameter passed in is a string containing the depot location

## followed by whitespace, followed by a local location

## e.g:

## “//Development/Product/Branch/… //workspace/Path/Name/Here…”

## Returns the Depot path and the local path for the provided

viewspec line  
def SourceControl.parseViewSpecLine(line)  
depot = []  
local = []  
state = :findDepot  
line.each\_byte do |b|  
ch = b.chr # convert to ascii  
case state  
when :findDepot  
depot \<\< ch if ch !~ /\s/  
state = :findDepotQuoted if ch == “"” ## ← Ln 63 HERE!!  
state = :findPath if ch =~ /\s/  
when :findDepotQuoted  
depot \<\< ch  
state = :findDepot if ch == “"”  
when :findPath  
local \<\< ch  
end  
end  
# Join the character arrays in a string and return an array of the  
two  
[depot.join, local.join]  
end

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [April 18, 2007, 11:01pm UTC](https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381/5 "2007-04-18T23:01:06Z")

</div>

On Apr 18, 4:40 pm, Ben [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Apr 18, 4:33 pm, Ben [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I’ll post the code
> 
> I should mention that this is called once for each line in the  
> Perforce view, and it is not crashing on the first call.

Because I love monologuing . . .

On a hunch I added a GC.start right after the first call, and it  
crashes there now, so I guess p4ruby doesn’t care for garbage  
collection. ☹ So y’all were right - I should contact the p4ruby  
author. Thanks!

-Ben

---

<div class="post-metadata">

**Author:** ![ben](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@ben](https://www.ruby-forum.com/u/ben)\
**Post date:** [April 18, 2007, 10:46pm UTC](https://www.ruby-forum.com/t/ruby-crashes-on-windows-across-three-versions/92381/6 "2007-04-18T22:46:04Z")

</div>

On Apr 18, 4:33 pm, Ben [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ll post the code

I should mention that this is called once for each line in the  
Perforce view, and it is not crashing on the first call.
