Skip to content

segmentation fault while building Linux From Scratch 12.4 #744

Description

@aerospaced

Title:

Flex 2.6.4 stage1flex bootstrap segmentation fault while building Linux From Scratch 12.4 temporary toolchain

Summary

While building Flex 2.6.4 as part of the Linux From Scratch (LFS) 12.4 temporary toolchain (Chapter 6), the bootstrap executable stage1flex consistently crashes with a segmentation fault while processing scan.l.

The failure is completely reproducible from a clean source tree.

Host Environment

Operating System:

Linux Mint 20.3 (Una)
Ubuntu 20.04 base

Kernel:

Linux media-server 5.4.0-216-generic
x86_64

glibc:

ldd (Ubuntu GLIBC 2.31-0ubuntu9.18) 2.31

Build Environment

Linux From Scratch 12.4
Chapter 6 temporary toolchain

Compiler:

x86_64-lfs-linux-gnu-gcc (GCC) 14.2.0

Environment:

LFS=/media/10tb/lfs/system
LFS_TGT=x86_64-lfs-linux-gnu

PATH=/media/10tb/lfs/system/tools/bin:/usr/bin:/bin

Building as the unprivileged user:

lfs

Configure Command

./configure
--prefix=/usr
--host=x86_64-lfs-linux-gnu
--build=$(build-aux/config.guess)

No custom CFLAGS were supplied.

Failure

Build proceeds normally until bootstrap.

Command executed by make:

./stage1flex -o stage1scan.c ./scan.l

Result:

Segmentation fault (core dumped)

Reproducibility

Failure is 100% reproducible.

Repeated after:

rm -rf flex-2.6.4
tar -xf flex-2.6.4.tar.gz

Configured again exactly as documented by LFS.

Same result every time.

Verification

Verified:

✓ clean source tree

✓ clean configure

✓ no CONFIG_SITE

✓ no custom CFLAGS

✓ correct LFS environment

✓ correct cross compiler

✓ stage1flex --version works

✓ stage1flex --help works

Only processing scan.l causes the segmentation fault.

stage1flex

stage1flex --version

stage1flex 2.6.4

stage1flex --help

Displays correctly.

Dynamic libraries

ldd ./stage1flex

linux-vdso.so.1

libm.so.6

libc.so.6

ld-linux-x86-64.so.2

GDB Backtrace

Program received signal SIGSEGV, Segmentation fault.

yyensure_buffer_stack()

#0 yyensure_buffer_stack()
#1 yyensure_buffer_stack()
#2 flexscan()
#3 yylex()
#4 yyparse()
#5 readin()
#6 flex_main()
#7 __libc_start_main()
#8 _start()

GDB Inspection

At first breakpoint:

yy_buffer_stack = NULL

yy_buffer_stack_max = 0

yy_buffer_stack_top = 0

After allocation:

yy_buffer_stack = 0x555ebc90

yy_buffer_stack_max = 0

Segmentation fault occurs inside yyensure_buffer_stack().

Question

Is this a known bootstrap issue with Flex 2.6.4 under cross-compilation?

Is there an upstream patch that should be applied?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions