Brakeman generating exceptions on an empty file - ruby-on-rails

After upgrading recently to brakeman 3.3.5 I am getting a similar exception on two files. One is app/helpers/profile_mailer and the exception is
golf_mentor/app/helpers/profile_helper.rb:1 :: parse error on value ":" (tCOLON)
If I delete everything but the surrounding block, so the file becomes
module ProfilesHelper
end
I still get the same exception. If I delete everything in the file, I get the following exception:
undefined method `force_encoding' for nil:NilClass While processing app/helpers/profiles_helper.rb
Looking on stackoverflow, such an error is not reported for brakeman, but it appears to be reported for a number of other apps and is related to ruby 2.2 (I am running 2.2.1).
The file permissions for this file are
-rw-r--r-- 1 Chris staff 4 16 Aug 19:57 profiles_helper.rb
How do I fix this?

Related

Magento - Fatal error: Maximum function nesting level of '100' reached, aborting

I don't know what is causing this error. I was working on a custom module on my Magento store and didn't check the homepage of the store regularly. Out of the blue today I am getting this error on my homepage.
Fatal error: Maximum function nesting level of '100' reached, aborting! in C:\Program Files\EasyPHP-5.3.8.0\www\indieswebs\lib\Zend\Db\Adapter\Pdo\Mysql.php on line 1045
The funny thing is there is NO 1045 line number in this file! So I am guessing it's some sort of looping error. But I don't know what is causing it. Can anyone help me figure out what might be causing this particular error and how can I remove it?
Edit:I deleted the cache from the store and reloaded the homepage. The error has changed now. It says:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 261904 bytes) in C:\Program Files\EasyPHP-5.3.8.0\www\indieswebs\lib\Zend\Db\Select.php on line 281
Does anyone know how to resolve this?
The error only come when you installed xdebug.
Use following setting in php.ini
xdebug.max_nesting_level = 200
I was able to resolve a related issue (that causes the same error message) by checking the files in [webroot]/app/etc/
It was happening (on enterprise edition) because
config.xml
enterprise.xml
were missing from that directory. Once I put them back, that fixed this problem.
I also read elsewhere that a malformed local.xml might cause this issue.
On enterprise edition, use something like:
<default_setup>
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[some_user]]></username>
<password><![CDATA[some_pass]]></password>
<dbname><![CDATA[database_name]]></dbname>
<active>1</active>
</connection>
</default_setup>
On CE, use something like:
<default_setup>
<connection>
<host><![CDATA[localhost]]></host>
<username><![CDATA[your_user]]></username>
<password><![CDATA[your_pass]]></password>
<dbname><![CDATA[your_db]]></dbname>
<initStatements><![CDATA[SET NAMES utf8]]></initStatements>
<model><![CDATA[mysql4]]></model>
<type><![CDATA[pdo_mysql]]></type>
<pdoType><![CDATA[]]></pdoType>
<active>1</active>
</connection>
</default_setup>
I got this in my Collection.php model, and the culprit turned out to be the call to parent::__construct(). Once I remmed it out the error went away. PS: Raising xdebug nesting level limit did not work.

Authlogic save causing 502 Bad Gateway error, Illegal Instruction in Rails console

I recently set up a new app server (Ruby 1.8.7 REE, Rails 2.3.8, Passenger 3.0.9, Nginx 1.0.6) behind a proxy and am encountering some strange behavior. When posting to /login on this app server alone, I get a 502 Bad Gateway error. This does not happen on the other app server, and both are set up identically. I've narrowed the problem down to a specific line of code - the saving of an Authlogic session. When I comment out these lines (specifically the save call):
#user_session = UserSession.new(params[:user_session])
if #user_session.save
...
the 502 error no longer occurs. Likewise, when I test these commands in the console, I get an Illegal Instruction response and the console crashes:
>> Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
>> #user_session = UserSession.new({"password"=>"password", "remember_me"=>"0", "login"=>"myuser"})
>> #user_session.save
Illegal instruction
Testing this on the other app server works just fine (console does not crash with Illegal Instruction result).
Any idea where to begin troubleshooting this? I see nothing of value in either the Rails logs or the Nginx logs.
Thanks.
Edit
The Illegal Instruction is occurring during a system call to digest.rb. The same thing happens whether I use the Ubuntu Ruby Enterprise Edition package or whether I compile it myself:
stat("/opt/ruby-enterprise-1.8.7-2011.12/lib/ruby/1.8/digest.rb", {st_mode=S_IFREG|0644, st_size=1145, ...}) = 0
open("/opt/ruby-enterprise-1.8.7-2011.12/lib/ruby/1.8/digest.rb", O_RDONLY) = 15
fstat(15, {st_mode=S_IFREG|0644, st_size=1145, ...}) = 0
close(15) = 0
--- SIGILL (Illegal instruction) # 0 (0) ---
This sounds like it's related to Ruby 1.9 Ramaze App Failing with “Illegal instruction”.
Jörg W Mittag said:
"Illegal instruction" is usually an error message from the CPU meaning some piece of binary code you tried to run contained an instruction that is not implemented on that particular CPU.
This can have multiple reasons:
The binary was compiled with optimization settings for the wrong CPU. The CPU vendors add new instructions all the time, if the compiler optimizes for a CPU that is newer than the one you have, it might have emitted an instruction that your CPU doesn't understand.
The compiler is broken.
The binary is corrupted.
The code you are compiling contains assembly code or intrinsics containing instructions that your CPU doesn't have.
The original question submitter Phil Kulak replied that he had found a stack overflow causing the error.

jRuby error - can't modify frozen array

I keep getting this error in my App, no matter what I try to fix.
"can't modify frozen array"
Any idea what could be possibly wrong here? I am running a jRuby (1.6.2) app on Torquebox (1.0.1) on my local Ubuntu (10.04) machine. Here is a complete stack trace
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.jruby.exceptions.RaiseException: (TypeError) can't modify frozen array
org.torquebox.rack.core.servlet.RackFilter.doRack(RackFilter.java:118)
org.torquebox.rack.core.servlet.RackFilter.doFilter(RackFilter.java:103)
org.torquebox.rack.core.servlet.RackFilter.doFilter(RackFilter.java:75)
root cause
org.jruby.exceptions.RaiseException: (TypeError) can't modify frozen array
org.jruby.RubyArray.concat(org/jruby/RubyArray.java:1450)
#<Class:0x1009c9a44>.Plugin(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/plugin.rb:71)
org.jruby.RubyKernel.instance_exec(org/jruby/RubyKernel.java:2045)
rubyjit.run_7761DFB9328DE427D0E75A527B886E70C475D69F.run(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:25)
#<Class:0x1000dfe45>.run_initializers(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:50)
org.jruby.RubyArray.each(org/jruby/RubyArray.java:1602)
Rails::Initializable.run_initializers(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/initializable.rb:49)
Rails::Application.initialize!(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:134)
rubyjit.method_added_79E9152BC344C327B5B6A61AD8A4DB7112D305D2.method_added(classpath:/org/torquebox/rails/core/boot.rb:78)
org.jruby.RubyKernel.send(org/jruby/RubyKernel.java:2059)
#<Class:0x101305815>.method_missing(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77)
#<Class:0x1002cf032>.(root)(vfs:/home/Ruby_Projects/Sample-Torquebox-App/config/environment.rb:5)
org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1038)
rubyjit.require_48BC09453A4C02A82A5E47520814DA9EA3718525.require(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/polyglot-0.3.1/lib/polyglot.rb:64)
rubyjit.require_3E6CA858403268171F46C45451765CD50640768C.require(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239)
rubyjit.load_dependency_04443C3CFAC2D53B173F0FF308908A72BD893CCC.load_dependency(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:227)
rubyjit.require_3E6CA858403268171F46C45451765CD50640768C.require(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239)
#<Class:0x101f38e01>.(root)(vfs:/home/Ruby_Projects/Sample-Torquebox-App/config/environment.rb:6)
org.jruby.RubyKernel.instance_eval(org/jruby/RubyKernel.java:2028)
Rack::Builder.initialize(/home/torquebox-1.0.1/jruby/lib/ruby/gems/1.8/gems/rack-1.2.3/lib/rack/builder.rb:46)
#<Class:0x1002cf032>.(root)(vfs:/home/Ruby_Projects/Sample-Torquebox-App/config.ru:3)
note The full stack trace of the root cause is available in the JBoss Web/3.0.0-CR1 logs.
JBoss Web/3.0.0-CR1
If you get the error during startup, chances are big you're actually trying to redefine a frozen array in an initializer (could be as simple as redifining ABBR_DAYNAMES). If the application can run under MRI you could try that, since it gives you verbose warnings about this.
If there's nothing in your initializer, then it might be a gem that you included in your application. Try taking out gems one by one and see what the result is.

error using doctrine:build --all symfony 1.4.4 apostrophe trunk

I'm stumped on why when I do doctrine:build -all it throws 2 warnings.
I've tried commenting out all the schema.yml files and it still throws it.
Anyone better informed help me understand where it is coming from, is there some caching I am unaware of?
I've deleted the cache (./symfony cc). Manually deleted all the lib/ models, forms, filters tasks so that there isn't anything hanging around and to no avail. I can't find anything on google for the error so I'm pretty stuck, I want to understand where the error is coming from, it's very early on in the process so I presume it is yaml related but I don't know how to track down where.
Cheers,
Paul
Shell output section Below:
doctrine generating model classes
PHP Warning: array_merge(): Argument #2 is not an array in /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBaseTask.class.php on line 182
PHP Stack trace:
PHP 1. {main}() /mnt/Target01/338166/www.example.co.uk/web/symfony:0
PHP 2. include() /mnt/Target01/338166/www.example.co.uk/web/symfony:14
PHP 3. sfSymfonyCommandApplication->run() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/command/cli.php:20
PHP 4. sfTask->runFromCLI() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/command/sfSymfonyCommandApplication.class.php:76
PHP 5. sfBaseTask->doRun() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfTask.class.php:97
PHP 6. sfDoctrineBuildTask->execute() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfBaseTask.class.php:68
PHP 7. sfTask->run() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBuildTask.class.php:156
PHP 8. sfBaseTask->doRun() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfTask.class.php:173
PHP 9. sfDoctrineBuildModelTask->execute() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfBaseTask.class.php:68
PHP 10. sfDoctrineBaseTask->prepareSchemaFile() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBuildModelTask.class.php:67
PHP 11. array_merge() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBaseTask.class.php:182
Warning: array_merge(): Argument #2 is not an array in /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBaseTask.class.php on line 182
Call Stack:
0.0008 47204 1. {main}() /mnt/Target01/338166/www.example.co.uk/web/symfony:0
0.0136 279748 2. include('/mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/command/cli.php') /mnt/Target01/338166/www.example.co.uk/web/symfony:14
0.9075 7815564 3. sfSymfonyCommandApplication->run() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/command/cli.php:20
0.9419 7817164 4. sfTask->runFromCLI() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/command/sfSymfonyCommandApplication.class.php:76
0.9433 7818056 5. sfBaseTask->doRun() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfTask.class.php:97
1.0198 8445008 6. sfDoctrineBuildTask->execute() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfBaseTask.class.php:68
2.0900 9762304 7. sfTask->run() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBuildTask.class.php:156
2.0907 9764724 8. sfBaseTask->doRun() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfTask.class.php:173
2.0926 9766452 9. sfDoctrineBuildModelTask->execute() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/task/sfBaseTask.class.php:68
2.1560 9789556 10. sfDoctrineBaseTask->prepareSchemaFile() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBuildModelTask.class.php:67
4.3235 10119764 11. array_merge() /mnt/Target01/338166/www.example.co.uk/web/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/task/sfDoctrineBaseTask.class.php:182
file+ /tmp/doctrine_schema_70082.yml
I just stumbled over the same error. I had an error in my schema.yml by definining an empty table name:
SomeTableNameThatShouldHaveBeenRemoved:
SomeOtherTableName:
colums:
id: etc. pp
Rather easy to spot one would think, yet when such a vague warning is thrown ...

symfony 1.4: error with include_once()

after installing sfDoctrineApplyPlugin-1.1.1, extracting Zend at
lib/vendor/Zend, executing sfApply/apply and submitting the form that
appears i get this errror:
Warning:
include_once(Zend/Loader/Autoloader.php)
[function.include-once]: failed to
open stream: No such file or directory
in
/home/ptiteshina/workspace/sfprojects/moonrave/plugins/sfDoc
trineApplyPlugin/modules/sfApply/lib/BasesfApplyActions.clas
s.php on line 350
Warning: include_once()
[function.include]: Failed opening
'Zend/Loader/Autoloader.php' for
inclusion
(include_path='/home/ptiteshina/workspace/sfprojects/moonrav
e/lib/vendor:.:/usr/share/php:/usr/share/pear')
in
/home/ptiteshina/workspace/sfprojects/moonrave/plugins/sfDoc
trineApplyPlugin/modules/sfApply/lib/BasesfApplyActions.clas
s.php on line 350
Fatal error: Class
'Zend_Loader_Autoloader' not found in
/home/ptiteshina/workspace/sfprojects/moonrave/plugins/sfDoc
trineApplyPlugin/modules/sfApply/lib/BasesfApplyActions.clas
s.php on line 351
If i write
include_once('/opt/lampp/htdocs/rs7/lib/vendor/Zend/library/Zend/Loader/Autoloader.php');
the error disappears, but you know, i can not use absolute paths.
I tried with some piece of paths instead but it didn't work.
Any idea?
Javi
Did you read Installing and configuring the Zend Framework part of a jobeet tutorial? There's a simple way to use Zend autoloader in a ProjectConfiguration.

Resources