[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Topics about GNUstep/libobjc2
From: |
David Chisnall |
Subject: |
Re: Topics about GNUstep/libobjc2 |
Date: |
Mon, 24 Oct 2016 20:09:24 +0100 |
Hi Rolf,
With the non-fragile ABI, it isn’t safe to assume that classes have the same
layout as C structs. This works with the fragile ABI, because the compiler is
entirely responsible for layout there. It sounds as if #pragma pack is
removing some padding that the ABI mandates for C structs, but which the
Objective-C runtime is not adding.
David
> On 24 Oct 2016, at 17:52, Dr. Rolf Jansen <rj@obsigna.com> wrote:
>
> Would it be OK to discuss on this list topics about Objective-C development
> involving clang + GNUstep/libobjc2, but almost nothing else from GNUstep?
>
> I constructed my own root class having only the bare basic methods that are
> needed by a quite old project, that I revamped for inclusion into a new plain
> C project. My class/code is working well on FreeBSD 11.0 RELEASE-p1 (amd64)
> when compiled with clang 3.8 (system) with -O0 or -Os and linked against
> libobjc2 1.8.1 (ports). Once compiled with any other optimization mode, it
> crashes (Bus Error) when accessing a certain instance variable struct.
>
> It is working well on Mac OS X 11.12 when compiled in any -O mode with my
> root class and linked against the native ObjC runtime. It is almost always
> working on FreeBSD 11 in any -O mode when using NSObject as the root class
> and linked against libobjc2 1.8.1 and gnustep-base (ports), although, I saw 2
> random crashes.
>
> After some debugging I found a workaround. Once I add a #pragma pack(8)
> directive at the top of the headers that declare my class hierarchy + all the
> C structs that are used throughout, the code with my root class works well on
> FreeBSD 11 when compiled in any -O mode -- a pack(4) does work as well.
>
> It is still possible that something is wrong with my code. However, after
> these many experiments, I tend to assume that the Objective-C runtime and the
> compiler sometimes disagree on correct packing/alignment of instance
> variables in instantiated objects. I can't tell, though, if the runtime or
> the compiler is responsible for this.
>
> In the case that it is appropriate to discuss this further on this list, I am
> ready to send more information. If this is not the appropriate list, then
> please may I ask for advise on which location this topic may be discussed.
>
> The #pragma pack(8) does neither cost anything nor is it a very ugly hack, so
> perhaps, it isn't even worth to discuss this issue furthermore, given that
> clang 4.0 may be out soon.
>
> Best regards
>
> Rolf
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep
- Topics about GNUstep/libobjc2, Dr. Rolf Jansen, 2016/10/24
- Re: Topics about GNUstep/libobjc2,
David Chisnall <=
- Re: Topics about GNUstep/libobjc2, Dr . Rolf Jansen, 2016/10/24
- Re: Topics about GNUstep/libobjc2, David Chisnall, 2016/10/25
- Re: Topics about GNUstep/libobjc2, Dr. Rolf Jansen, 2016/10/25
- Re: Topics about GNUstep/libobjc2, David Chisnall, 2016/10/25
- Re: Topics about GNUstep/libobjc2, David Chisnall, 2016/10/25
- Re: Topics about GNUstep/libobjc2, Dr. Rolf Jansen, 2016/10/25
- Re: Topics about GNUstep/libobjc2, Dr. Rolf Jansen, 2016/10/25