Tuesday, July 31, 2012

Fighting make error: not protecting function: no buffer at least 8 bytes long

Attempting to build monetdb from source. The mercurial checkout date is not today but somewhere around start of July.

Getting the following error saying something like:
cc1: warnings being treated as errors - this is due to -Werror flag to gcc


inet.c: In function ‘INET_comp_CW’:
inet.c:323: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETbroadcast’:
inet.c:423: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETnetmask’:
inet.c:523: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETnetwork’:
inet.c:593: error: not protecting function: no buffer at least 8 bytes long
inet.c: In function ‘INETabbrev’:
inet.c:660: error: not protecting function: no buffer at least 8 bytes long
make[7]: *** [libatoms_la-inet.lo] Error 1
 - due to -fstack-protector-all -Wstack-protector flags to gcc. For more info on stack protector feature refer http://stackoverflow.com/questions/1629685/when-and-how-to-use-gccs-stack-protection-feature


The explanation at http://ubuntuforums.org/showthread.php?t=1612849 was sufficient for fixing.

Went to those line numbers.  They were the entry point of the reported functions.
Found unsigned char[4] local variables. Changed them to char[8].

Owned it.

Regards,
Tapomay.

Design patterns in Ruby


http://rubylearning.com/blog/2010/11/02/how-does-one-use-design-patterns-in-ruby/ :


I believe that the essence of design patterns is to make a system resilient to changes in requirements which in itself could be attributed with the parameters associated with the problem definition. The above article helped me with a lucid set of ruby examples demonstrating following patterns:
(The comments are for my personal notes. Plz ignore them)
1. Inheritance  : Car < Vehicle
2. Composition over inheritance : Car<Vehicle, Car->Engine
3. Delegation ; Car<Vehicle, Car->Engine
4. Template Method pattern : HTMLReport<Report, TextReport<Report
5. Singleton pattern : require 'singleton', attr_accessor :data
6. Adapter pattern : Renderer, TextObject, DifferentTextObject, TextObjectAdapter, class << diff_text_obj

Thanks and Regards,
Tapomay