I try to call a function in an external dynamic library from Ruby, but got 
stack size too deep error,
my ruby code is very simple, so unlikely I have infinite recursive loop in 
Rudy's side,
I actually created a simple external libsum.dylib just to return the sum of 
first three parameters
and it works well. libsamplesize.dylib works before in older version of 
RubyOnRails, so I
am sure there is no infinite recursive loop inside the library. When I try 
"compute", it takes forever
to finish, I wonder if stack size needed is over the limit and is there a 
way to increase it?

Thanks!
Liz
....

  require 'fiddle/import'

  module Libm
    extend Fiddle::Importer
    dlload '/Library/WebServer/smart/lib/libsamplesize.dylib'
    extern 'long Calculate(long, double, double, char*)'
  end

def compute

  require 'fiddle'
#    require 'pathname'

#    if ( session[:sigma_sq] <= 0.0 )
#      session[:errmsg] = "The value of sigma-squared must be positive."
#      session[:n] = -1
#    elsif ( session[:delta] < 0.0 ) || ( session[:delta] > 1.0 )
    if ( session[:delta] < 0.0 ) || ( session[:delta] > 1.0 )
      session[:errmsg] = "The value of delta must be between 0 and 1."
      session[:n] = -1
    elsif ( session[:conf] < 0.0 ) || ( session[:conf] > 1.0 )
      session[:errmsg] = "The value of conf must be between 0 and 1."
      session[:n] = -1
    elsif ( session[:nmax] < 0.0 )
      session[:errmsg] = "The value of nmax must be positive."
      session[:n] = -1
    else

       session[:errmsg] = 
"                                                                               
 
";
       session[:n] = Libm.Calculate( session[:nmax], session[:delta],
                          session[:conf], session[:errmsg])
    end
    redirect_to :action => "results"
  end

  def results
    # @sigma_sq = session[:sigma_sq]
    @delta = session[:delta]
    @conf = session[:conf]
    @nmax = session[:nmax]
    @n = session[:n]
    @errmsg = session[:errmsg]
  end
 ....
 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/ab760ee2-dda3-4806-97ab-9f2fa95de0a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to