When I run my Ruby on Rails application locally, it keeps crashing on one particular page. Whenever I load the page, I get the following error from Ruby.exe:
The instruction at [address] referenced memory at [address]. The memory could not be “written”.
Once this error happens, the server crashes and I have to restart with ‘rails s’. I’ve tried cutting out/commenting out various partials and functions to try and tell if a single section is causing it, but I continue to get this error. This happens in different browsers (both firefox and chrome). The crash occurs when I am running my application on my localhost.
I’m using ruby version 1.9.2p290, Rails 3.0.9 and Windows XP SP3. My coworker is having the same problem with the same setup. We both used the windows XP RubyInstaller to install Ruby. When I started getting this error, I downloaded and ran the installer again but that didn’t solve the problem.
Does anyone have any idea what could be causing this error, or how I might figure out what the problem is? I can post more code if necessary.
Out of many similar pages on the web application we’re working on, only one page crashes in this way. The code for the page (edit.html.erb) is below:
<script type="text/javascript">
set_toolbar("projects", "<%= @project.id %>", "", "", "edit");
</script>
<%= render :partial => "sidebars/sidebar", :locals => {:curr_page => "info"} %>
<%= render :partial => "page_title", :locals => {:page_title => "Project Information"} %>
Use this form to modify your project, then click the "Save and Continue" button
to follow the process shown at the right.
<br/><br/>
<%= render "projects/form" %>
<div id="add_keyquestion_box">
<%= render "key_questions/form" %>
</div>
<script type="text/javascript">
$("#add_keyquestion_box").dialog({
autoOpen: false,
minWidth: 600
});
</script>
The partials “projects/form” and “key_questions/form” are both included in a similar page, new.html.erb, in the exact same way and that page does not crash.
UPDATE: Okay, so while pondering this problem and concurrently working on other things, we temporarily removed CKEditor from both the projects/form partial and the key_questions/form partial. Although I had tried this previously (grrr) it appears to have stopped the crashing this time. Possibly I wasn’t thorough enough last time in my removal of it.
Whenever the CKEditor existed in new.html.erb, the page would work normally and data would save normally.
BUT when the CKEditor existed in edit.html.erb, with data already in the form, the crash described above would happen. This would sometimes take place after the editor itself loaded partially or completely, or sometimes before the editor loaded at all. The crash seems to have to do with information being pulled from the database to be displayed for editing in CKEditor.
Further information about how we were using CKEditor: in the “projects/form” partial, two CKEditors are created within the page. The “key_questions/form” partial is located within a jQuery dialog box that appears when a user clicks on a button contained in “projects/form”. The functionality for this button is contained in “projects/form” and looks like this:
<script type="text/javascript">
$("#add_kq_button").bind("click", function(event)
{
event.preventDefault();
$.ajax({
url: 'key_questions/new',
type: "POST",
data: { project: <%= @project.id.nil? ? -1 : @project.id %>}
});
});
</script>
key_questions/new.js.erb calls the necessary dialog open function in jQuery to open the key question form dialog.
Thanks for any suggestions you can give!
Have you tried using the thin server instead? If you add thin to your Gemfile, run
bundle installthen dobundle exec rails server thin -e developmentthen you might find many crash issues disappear – I certainly did.