Skip to content

Build failure with -fsanitize=undefined #130411

Closed as duplicate
Closed as duplicate

Description

@srinivasreddy

Bug report

Bug description:

export LDFLAGS="-fsanitize=undefined"
export CFLAGS="-fsanitize=undefined -fno-sanitize-recover=all -g"
./configure --enable-shared --with-pydebug
make -j8

Please see the part of the output where error occured,

gcc -bundle -undefined dynamic_lookup -fsanitize=undefined -fsanitize=undefined    Modules/sha2module.o  Modules/_hacl/libHacl_Hash_SHA2.a  -o Modules/_sha2.cpython-314d-darwin.so
gcc -bundle -undefined dynamic_lookup -fsanitize=undefined -fsanitize=undefined    Modules/blake2module.o  Modules/_hacl/libHacl_Hash_Blake2.a  -o Modules/_blake2.cpython-314d-darwin.so
gcc -bundle -undefined dynamic_lookup -fsanitize=undefined -fsanitize=undefined    Modules/pyexpat.o -lm Modules/expat/libexpat.a  -o Modules/pyexpat.cpython-314d-darwin.so
gcc -bundle -undefined dynamic_lookup -fsanitize=undefined -fsanitize=undefined    Modules/_elementtree.o   -o Modules/_elementtree.cpython-314d-darwin.so
gcc -c -fno-strict-overflow -Wsign-compare -g -Og -Wall -fsanitize=undefined -fno-sanitize-recover=all -g -fsanitize=undefined -fno-sanitize-recover=all -g  -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -Werror=unguarded-availability  -I./Include/internal -I./Include/internal/mimalloc  -I. -I./Include    -DPy_BUILD_CORE \
	      -DGITVERSION="\"`LC_ALL=C git --git-dir ./.git rev-parse --short HEAD`\"" \
	      -DGITTAG="\"`LC_ALL=C git --git-dir ./.git describe --all --always --dirty`\"" \
	      -DGITBRANCH="\"`LC_ALL=C git --git-dir ./.git name-rev --name-only HEAD`\"" \
	      -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
gcc -fsanitize=undefined -fsanitize=undefined   -o Programs/_freeze_module Programs/_freeze_module.o Modules/getpath_noop.o Modules/getbuildinfo.o Parser/token.o  Parser/pegen.o Parser/pegen_errors.o Parser/action_helpers.o Parser/parser.o Parser/string_parser.o Parser/peg_api.o Parser/lexer/buffer.o Parser/lexer/lexer.o Parser/lexer/state.o Parser/tokenizer/file_tokenizer.o Parser/tokenizer/readline_tokenizer.o Parser/tokenizer/string_tokenizer.o Parser/tokenizer/utf8_tokenizer.o Parser/tokenizer/helpers.o Parser/myreadline.o Objects/abstract.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/call.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genericaliasobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/picklebufobject.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/typevarobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/unionobject.o Objects/weakrefobject.o  Python/_warnings.o Python/Python-ast.o Python/Python-tokenize.o Python/asdl.o Python/assemble.o Python/ast.o Python/ast_opt.o Python/ast_unparse.o Python/bltinmodule.o Python/brc.o Python/ceval.o Python/codecs.o Python/codegen.o Python/compile.o Python/context.o Python/critical_section.o Python/crossinterp.o Python/dynamic_annotations.o Python/errors.o Python/flowgraph.o Python/frame.o Python/frozenmain.o Python/future.o Python/gc.o Python/gc_free_threading.o Python/gc_gil.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/ceval_gil.o Python/hamt.o Python/hashtable.o Python/import.o Python/importdl.o Python/index_pool.o Python/initconfig.o Python/interpconfig.o Python/instrumentation.o Python/instruction_sequence.o Python/intrinsics.o Python/jit.o Python/legacy_tracing.o Python/lock.o Python/marshal.o Python/modsupport.o Python/mysnprintf.o Python/mystrtoul.o Python/object_stack.o Python/optimizer.o Python/optimizer_analysis.o Python/optimizer_symbols.o Python/parking_lot.o Python/pathconfig.o Python/preconfig.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/qsbr.o Python/bootstrap_hash.o Python/specialize.o Python/stackrefs.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/thread.o Python/traceback.o Python/tracemalloc.o Python/uniqueid.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/suggestions.o Python/perf_trampoline.o Python/perf_jit_trampoline.o Python/dynload_shlib.o     Modules/config.o Modules/main.o Modules/gcmodule.o Modules/atexitmodule.o  Modules/faulthandler.o  Modules/posixmodule.o  Modules/signalmodule.o  Modules/_tracemalloc.o  Modules/_suggestions.o  Modules/_codecsmodule.o  Modules/_collectionsmodule.o  Modules/errnomodule.o  Modules/_io/_iomodule.o Modules/_io/iobase.o Modules/_io/fileio.o Modules/_io/bytesio.o Modules/_io/bufferedio.o Modules/_io/textio.o Modules/_io/stringio.o  Modules/itertoolsmodule.o  Modules/_sre/sre.o  Modules/_sysconfig.o  Modules/_threadmodule.o  Modules/timemodule.o  Modules/_typingmodule.o  Modules/_weakref.o  Modules/_abc.o  Modules/_functoolsmodule.o  Modules/_localemodule.o  Modules/_opcode.o  Modules/_operator.o  Modules/_stat.o  Modules/symtablemodule.o  Modules/pwdmodule.o -lintl -ldl  -framework CoreFoundation
./Programs/_freeze_module getpath ./Modules/getpath.py Python/frozen_modules/getpath.h
./Programs/_freeze_module importlib._bootstrap ./Lib/importlib/_bootstrap.py Python/frozen_modules/importlib._bootstrap.h
./Programs/_freeze_module importlib._bootstrap_external ./Lib/importlib/_bootstrap_external.py Python/frozen_modules/importlib._bootstrap_external.h
./Programs/_freeze_module zipimport ./Lib/zipimport.py Python/frozen_modules/zipimport.h
Python/gc.c:1458:16: runtime error: call to function namespace_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)'
namespaceobject.c:173: note: namespace_traverse defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/gc.c:1458:16 in
make: *** [Python/frozen_modules/importlib._bootstrap.h] Abort trap: 6
make: *** Waiting for unfinished jobs....
Python/gc.c:1458:16: runtime error: call to function namespace_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)'
namespaceobject.c:173: note: namespace_traverse defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/gc.c:1458:16 in
make: *** [Python/frozen_modules/importlib._bootstrap_external.h] Abort trap: 6
Python/gc.c:2189:11: runtime error: call to function inst_seq_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)'
instruction_sequence.c:402: note: inst_seq_traverse defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/gc.c:2189:11 in
make: *** [Python/frozen_modules/getpath.h] Abort trap: 6
Python/gc.c:1458:16: runtime error: call to function namespace_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)'
namespaceobject.c:173: note: namespace_traverse defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/gc.c:1458:16 in
make: *** [Python/frozen_modules/zipimport.h] Abort trap: 6

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Activity

  1. srinivasreddy commented on Feb 21, 2025

    @srinivasreddy
    ContributorAuthor

    Especially the part,

    Python/gc.c:2189:11: runtime error: call to function inst_seq_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)'
    instruction_sequence.c:402: note: inst_seq_traverse defined here
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/gc.c:2189:11 in
    make: *** [Python/frozen_modules/getpath.h] Abort trap: 6
    Python/gc.c:1458:16: runtime error: call to function namespace_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)'
    namespaceobject.c:173: note: namespace_traverse defined here
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/gc.c:1458:16 in
    make: *** [Python/frozen_modules/zipimport.h] Abort trap: 6
    
  2. encukou commented on Feb 21, 2025

    @encukou
    Member

    Thank you for the report.
    We are aware of this. Unfortunately, these "incorrect function type" issues are in nearly all extenstion modules.
    @picnixz is in the middle of a massive effort to fix them inside CPython.

    We have a buildbot check to detect all other UBsan failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions