Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #148696

Re: UB awaits... (Was: Pointer goes to null)

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: UB awaits... (Was: Pointer goes to null)
Date 2020-01-02 23:34 +0100
Organization A noiseless patient Spider
Message-ID <qulr6b$op2$1@dont-email.me> (permalink)
References <9ba96621-32fb-403e-8241-4a23d84a0167@googlegroups.com> <qukso3$3ql$1@dont-email.me> <3XqPF.691098$kBJ1.374933@fx12.am4> <qulhnp$iqk$1@news.xmission.com>

Show all headers | View raw


On 02/01/2020 20:53, Kenny McCormack wrote:
> In article <3XqPF.691098$kBJ1.374933@fx12.am4>, Bart  <bc@freeuk.com> wrote:
> ...
>> Then you can't really assume anything about any program, for example
>> 'int' may be defined as:
>>
>>      #define int double
> 
> Pretty sure that produces UB.

It's a good starting point for the Obfuscated C competition.

> 
>> Most probably it isn't; and most probably u8 and u64 represent unsigned
>> 8- and 64-bit types.
> 
> Of course.  Still, Lew's point is valid.
> 

Yes - precisely because some people actually do stupid things.  Look at 
enough code, and you'll find someone who has written:

// typedef u8 unsigned char;
typedef u8 unsigned short int;		// Changed to avoid overflow


or simply:

typedef u32 unsigned long;

and then tried to port the code to 64-bit Linux.


In this particular case, I'd wonder if the bug lies in some code 
elsewhere, such as a pointer error in UBI256 that corrupts part of the 
stack leading to these symptoms.  It is always wise to boil the code 
down to a minimum /compilable/ snippet that can demonstrate the issue. 
(Also, that is a good exercise and often helpfully reveals the bug.)

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Pointer goes to null m.nasim85@gmail.com - 2020-01-02 01:34 -0800
  Re: Pointer goes to null Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-02 12:47 +0000
  Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-02 08:55 -0500
    Re: Pointer goes to null Bart <bc@freeuk.com> - 2020-01-02 18:49 +0000
      UB awaits... (Was: Pointer goes to null) gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-02 19:53 +0000
        Re: UB awaits... (Was: Pointer goes to null) David Brown <david.brown@hesbynett.no> - 2020-01-02 23:34 +0100
          Re: UB awaits... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-03 01:43 +0000
            Re: UB awaits... David Brown <david.brown@hesbynett.no> - 2020-01-03 09:50 +0100
              Re: UB awaits... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-03 14:30 +0000
                Re: UB awaits... David Brown <david.brown@hesbynett.no> - 2020-01-03 17:27 +0100
  Re: Pointer goes to null Bart <bc@freeuk.com> - 2020-01-02 14:07 +0000
    Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-02 07:29 -0800
      Re: Pointer goes to null Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-02 10:12 -0800
  Re: Pointer goes to null jak <nospam@please.ty> - 2020-01-02 16:46 +0100
  Re: Pointer goes to null Barry Schwarz <schwarzb@delq.com> - 2020-01-02 08:50 -0800
    Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-03 16:20 -0800
      Re: Pointer goes to null Barry Schwarz <schwarzb@delq.com> - 2020-01-03 22:16 -0800
        Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-07 03:21 -0800
      Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-07 12:24 -0500
        Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-07 12:38 -0500
          Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-15 09:36 -0800
            Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-15 18:36 +0000
              Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-15 17:31 -0500
                Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 02:20 +0000
                Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-17 14:51 -0800
                Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-17 23:32 +0000
              Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-17 14:47 -0800
                Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-17 23:25 +0000
            Re: Pointer goes to null James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-15 10:49 -0800
              Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-17 14:49 -0800
        Re: Pointer goes to null Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-07 09:42 -0800
          Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-15 09:40 -0800
  Re: Pointer goes to null James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-02 22:38 -0500

csiph-web