[Original] High version of GCC compilation Yo optimization may cause problems

Source: Internet
Author: User

System: ubuntu14.04

Compiler: gcc4.8.2

Problem Description: Work needs, use Libnids, so the latest version of the 1.24, after compiling the installation, found that the TCP message reorganization work can not be completed, specifically, although the NIDS_REGISTER_TCP function registered a callback function, but the function can not be executed, By tracing the Libnids execution process, it is found that there is a problem in the calculation of the checksum, the value of checksum is not zero, which leads to libnids that the datagram is corrupted.

Unknown so, but through thinking, think the problem should be on the compiler, is not the problem of 64-bit and 32? The source code does not use a long and other data types that can cause problems. Later thought of the compilation optimization, this is really the problem: when the high version of the GCC compiled with-O2 and above optimization level, The length of the structure may change (in order to speed up the addressing speed, the compiler optimizes the alignment), this time cannot use the manually calculated address offset, there is a problem.

Solution: Compile-time plus-fno-strict-aliasing option

Some of the connections you can refer to are:

https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1072650

http://edeca.net/wp/2014/03/libnids-on-64-bit-architecture-machines/

[Original] High version of GCC compilation Yo optimization may cause problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.