From: lxh37@... Date: 2014-08-21T14:54:56+00:00 Subject: [ruby-core:64489] [ruby-trunk - Bug #10133] Bug in ruby Issue #10133 has been updated by Liz Huang. I used fiddle in my Ruby script and it works! but when I use it in the same way on Ruby On Rails, it crashed. I pasted the codes below and you can see the codes are exactly the same. I am not sure if it is fiddle. Ruby script which works: class Samplesize 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' errmsg =" " puts Libm.Calculate( 1000, 0.2, 0.9, errmsg) end end Samplesize_controller.rb on Ruby On Rails that crashes when call "Libm.Calculate()". class SamplesizeController < ApplicationController require 'fiddle/import' module Libm extend Fiddle::Importer dlload '/Library/WebServer/smart/lib/libsamplesize.dylib' extern 'long Calculate(long, double, double, char*)' end def index end def progress # session[:sigma_sq] = params[:sigma_sq].to_f session[:delta] = params[:delta].to_f session[:conf] = params[:conf].to_f session[:nmax] = params[:nmax].to_i redirect_to :action => "compute" end def compute require 'fiddle' 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 errmsg =" " resultn= Libm.Calculate(1000,0.2,0.9, errmsg) session[:n] = resultn 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 def start_over reset_session redirect_to :action => "index" end end ---------------------------------------- Bug #10133: Bug in ruby https://bugs.ruby-lang.org/issues/10133#change-48436 * Author: Liz Huang * Status: Third Party's Issue * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: 2.1.0p0 (2013-12-25 revision 44422 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- I got a new Mac Pro server and tried to upgrade web applets to new version of Ruby On Rails, the web applet calls an external Fortran library I developed, it worked in Ruby on Rails (Ruby 1.8.7 and Rails 2.3.18) by using "DL". I tried to develop the same web applet in Ruby on Rails 4 (ruby 2.1.0p0 (2013-12-25 revision 44422) and Rails 4.1.2), with "DL" deprecated, so I use fiddle and wrapped Fortran by C, I tested the interface by commenting out all computation parts first to make sure it is working. Now I have the computation codes back (same codes as in older version) and I even create a console application to test the code is working. But when I try to call it from Ruby, it crashed. I saved all messages in terminal window in attached file "bug.rtf" and also send the crash report. I feel it might a bug in Ruby as it works in older version and the Fortran codes was tested in console application project. ---Files-------------------------------- bug.rtf (125 KB) ruby_2014-08-14-162519_calder229.crash (25 KB) DiagnosticReports.zip (1.21 MB) calculateSamplesize.rb (454 Bytes) libsamplesize.dylib (1.78 MB) ruby_2014-08-20-153628_calder229.crash (26.3 KB) -- https://bugs.ruby-lang.org/