vicoapp / vico

Mac Programmers Text Editor
http://www.vicoapp.com/
658 stars 89 forks source link

Enter causes app to crash at specific line in ruby #83

Closed riveramj closed 9 years ago

riveramj commented 10 years ago

Ruby code below causes the crash. At line:36 (inside create method).

To reproduce 1) place cursor at beginning of the line 2) open insert mode 3) hit enter.

It should crash before it inserts the line.

Vico is up to date. Ruby is ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

Lines from the crash report:

Application Specific Information:
abort() called
*** error for object 0x61000107b740: Freeing already free'd pointer

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff89d2a866 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff8f8e335c pthread_kill + 92
2   libsystem_c.dylib               0x00007fff93df4b1a abort + 125
3   libsystem_malloc.dylib          0x00007fff8cdf6bee nanozone_error + 486
4   libsystem_malloc.dylib          0x00007fff8cdf59a5 nano_free + 256
5   com.apple.CoreFoundation        0x00007fff8bb76c91 __CFStringDeallocate + 225
6   com.apple.CoreFoundation        0x00007fff8bb74448 CFRelease + 424
7   se.bzero.Vico                   0x000000010857fd99 -[ViLanguage compileRegexp:withBackreferencesToRegexp:matchText:] + 873 (ViLanguage.m:83)
8   se.bzero.Vico                   0x00000001085a08f5 -[ViSyntaxParser endMatchesForBeginMatch:inRange:] + 277 (ViSyntaxParser.m:393)
9   se.bzero.Vico                   0x00000001085a0bd8 -[ViSyntaxParser applyPatterns:inRange:openMatches:reachedEOL:] + 424 (ViSyntaxParser.m:437)
10  se.bzero.Vico                   0x00000001085a2d28 -[ViSyntaxParser highlightLineInRange:continueWithMatches:] + 760 (ViSyntaxParser.m:631)
11  se.bzero.Vico                   0x00000001085a34a9 -[ViSyntaxParser parseContext:] + 1321 (ViSyntaxParser.m:714)
12  se.bzero.Vico                   0x000000010856a035 -[ViDocument performSyntaxParsingWithContext:] + 277 (ViDocument.m:1283)
13  se.bzero.Vico                   0x000000010856a37e -[ViDocument dispatchSyntaxParserWithRange:restarting:] + 270 (ViDocument.m:1325)
14  se.bzero.Vico                   0x000000010856c0f4 -[ViDocument textStorageDidProcessEditing:] + 1444 (ViDocument.m:1540)
15  com.apple.CoreFoundation        0x00007fff8bc77e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
16  com.apple.CoreFoundation        0x00007fff8bb6b8dd _CFXNotificationPost + 2893
17  com.apple.Foundation            0x00007fff8e2047ba -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
18  com.apple.AppKit                0x00007fff941bd8fb -[NSTextStorage processEditing] + 135
19  com.apple.AppKit                0x00007fff940b6060 -[NSTextStorage edited:range:changeInLength:] + 340
20  se.bzero.Vico                   0x00000001085a8d34 -[ViTextStorage replaceCharactersInRange:withString:] + 2452 (ViTextStorage.m:408)
class ListingsController < ApplicationController

  layout "show", :only => [ :show ]
  before_action :set_listing, only: [:show, :edit, :update, :destroy]
  before_filter :require_current_user, only: [:new, :edit, :update, :destroy, :create]
  before_filter :validate_user, only: [:edit, :update, :destroy]

  def show
  end

  def index
    location = [params[:lat].to_f, params[:lng].to_f]
    @listing = Listing.closest(origin: location)
    redirect_to @listing
  end

  # GET /listings/new
  def new
    @listing = Listing.new
  end

  # GET /listings/1/edit
  def edit

  end

  # POST /listings
  # POST /listings.json
  def create
    @listing = current_user.listings.new(listing_params)

    respond_to do |format|
      if @listing.save
        format.html { redirect_to @listing, notice: 'Listing was successfully created.' }
        format.json { render action: 'show', status: :created, location: @listing }

        ListingConfirmation.new_listing(@listing).deliver

      else
        format.html { render action: 'new' }
        format.json { render json: @listing.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /listings/1
  # PATCH/PUT /listings/1.json
  def update
    respond_to do |format|
      if @listing.update(listing_params)
        format.html { redirect_to @listing, notice: 'Listing was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: 'edit' }
        format.json { render json: @listing.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /listings/1
  # DELETE /listings/1.json
  def destroy
    @listing.destroy
    respond_to do |format|
      format.html { redirect_to listings_url }
      format.json { head :no_content }
    end
  end

  private
    def set_listing
      @listing = Listing.find_by(permalink: params[:id])
    end

    def validate_user
      unless current_user.listings.any? { |listing| listing == @listing }
        redirect_to new_user_session_path
      end
    end

    def listing_params
      params.require(:listing).permit(
          :street1, :street2, :city, :state,
          :zip, :price, :features, :description,
          :permalink, :beds, :baths, :sqft, :home_type,
          :email, :phone,
          photos_attributes: [:full_url, :thumbnail_url, :caption, :width, :height])
    end
end
Shadowfiend commented 10 years ago

Double-free's pretty bizarre given our use of ARC. Something funkalicious is going on.

Shadowfiend commented 9 years ago

I remember having some issue reproducing this on my own machine… Is it still happening?

riveramj commented 9 years ago

I'm on macvim now so I couldn't tell ya. Feel free to close this and I'll reopen if I see it.

On Sat, Dec 13, 2014, 11:46 Antonio Salazar Cardozo < notifications@github.com> wrote:

I remember having some issue reproducing this on my own machine… Is it still happening?

— Reply to this email directly or view it on GitHub https://github.com/vicoapp/vico/issues/83#issuecomment-66882409.

Shadowfiend commented 9 years ago

Kk.