is54/uvselp: fix segfault by adding ANSI C prototypes#184
Open
ludomal wants to merge 1 commit into
Open
Conversation
Replace K&R-style empty-parentheses function declarations with proper ANSI C prototypes. The missing prototypes caused default argument promotion (float->double) at call sites, while function bodies expected float parameters. This ABI mismatch causes segfaults on GCC 6+, Clang, MSVC, and ARM64 platforms. Convert two K&R function definitions (RES_ENG, A_SST) to ANSI style. Fix all forward declarations in .c and .h files to include parameter types. Fix function pointer declarations for get_codes/put_codes. The existing tests verify the tool runs without crashing. Bit-exact output verification is not included because floating-point rounding produces platform-dependent results. Fixes openitu#132, Fixes openitu#41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix uvselp segfault on modern compilers (GCC 6+, Clang, MSVC)
Summary
Replace K&R-style empty-parentheses function declarations in
src/is54/with proper ANSI C prototypes. This fixes segfaults/crashes that occur with any modern compiler.Note that bit-exact output verification tests are not included because floating-point rounding produces platform-dependent results differing by more than ±1. This is pre-existing (#24) and inherent to float arithmetic, and original tests vectors could not be verified on any tested platforms (AMR64 and x86).
This PR:
Problem
The IS-54 VSELP codec uses 1990-era K&R function declarations:
When
FTYPEisfloat(the default), this triggers C default argument promotion: callers promotefloatarguments todoublebecause no prototype is visible. But the function bodies expectfloatparameters. This ABI mismatch causes:EXCITE.gsp0receives a garbage value because register assignments are shifted by the size mismatchassert(tmp >= 0)fails inRES_ENG(interp.c:134).rq0receives corrupted data, producing negative values undersqrtfloatis passed in S registers,doublein D registers, completely different register banksFix
Added proper ANSI C prototypes to all header files and converted K&R function definitions to ANSI style:
r_sub.ht_sub.hvselp.hvselp.cget_codes/put_codesfunction pointer declarationsinterp.cRES_ENGK&R definition to ANSI; fixATORCforward declmakec.cA_SSTK&R definition to ANSI; fixATORC,ATOCOR,LEVINSONforward declsg_quant.ccorrforward declarationlag.ci_respforward declarationThe internal precision remains
float(FTYPE). The fix only corrects the calling convention so arguments are passed in the correct registers/stack positions. The algorithm and arithmetic are unchanged.