[PATCH v2] libctf: ctf_member_next needs to return (ssize_t)-1 on error

Torbjorn SVENSSON torbjorn.svensson@foss.st.com
Fri Sep 8 12:58:04 GMT 2023



On 2023-09-07 14:10, Nick Alcock wrote:
> On 30 Aug 2023, Alan Modra via Binutils outgrape:
> 
>> On Wed, Aug 30, 2023 at 10:34:05AM +0200, Torbjorn SVENSSON wrote:
>>> @Alan, any additional comments on this updated patch (except the missing
>>> semicolon that I mention below)?
>>
>> I'm leaving it to Nick Alcock to decide what to do here.
> 
> I agree that we should indeed be returning -1 from all functions that
> return an int (it used to, but ctf_id_t has to be an unsigned long). But
> I think it might be less disruptive to do so via a new
> ctf_set_errno_int() which is just like ctf_set_errno but returns an int
> rather than an unsigned long. That eliminates a lot of {}ery and makes
> each individual hunk smaller.

Ok, I can do that instead if that's considered the proper way.

> My concern is that it's really hard to validate all this -- can anyone
> think of a trick that would emit *consistent* warnings if we called
> return (ctf_set_errno()) from a function returning int? I mean this
> returning-int thing is a change I made ages ago, and despite making it
> *and* attempting to validate on 64-bit Windows I have clearly not got it
> right because it's drifted right out of correctness again.
>
> (Similarly, does anyone have a build/target triplet on which this goes
> wrong? because it's not going wrong on any of my mingw64 or cygwin tests
> as far as I can tell.)

I discovered the issue using the GCC12 package for arm-none-eabi that 
Arm released 
(https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads), but 
built using the x86_64-w64-mingw GCC compiler on Linux.

I've opened a ticket for the issue where I've attached 2 object files 
that you can use to reproduce the issue without needing to rebuild GCC + 
multlibs to verify the problem.
https://sourceware.org/bugzilla/show_bug.cgi?id=30836

> I kinda wish we could rely on having C11 -- type-generic macros are made
> for cases like this :(

Looks like it would be a nice fix indeed, but is there anything else 
that could be done to improve the situation without needing to go to C11?

Kind regards,
Torbjörn


More information about the Binutils mailing list