Re: Sparse-LLVM issue compiling NULL pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Luc,

On 2 March 2017 at 13:56, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
> On Thu, Mar 02, 2017 at 05:41:59AM +0000, Dibyendu Majumdar wrote:
>> On 2 March 2017 at 05:21, Luc Van Oostenryck
>> <luc.vanoostenryck@xxxxxxxxx> wrote:
>> >> Anyway have hit a bunch of other issues with sparse-llvm ... :-(
>> >
>> > Each day its problem (and happily its solution too!).
>> >
>>
>> I will submit test cases for the new problems when I get some time.
>

Below is an example that fails for me. I am running a modified version
of Sparse although the modifications are to do with a) removing global
state and b) compiling with Visual C++ on Windows 10 - and all sparse
tests pass so I don't think they have anything to do with the failure
here. I do have Linux build of sparse but without LLVM so I will need
to sort that out to test. Anyway, I would be interested to know if you
get a failure (you will need to have LLVM assertions enabled).

typedef unsigned long long size_t;
struct buffer_type_st {
 struct buffer_type_st    *next_buffer;
 char           *buffer;
};
typedef struct buffer_type_st buffer_type_t;
struct link_st {
 struct link_st           *next;
};
typedef struct link_st link_t;
struct allocator_st {
 buffer_type_t    *buffer_list;
 link_t           *free_list;
 char           *next_avail;
 char           *last;
 size_t          size;
 size_t          n;
};
typedef struct allocator_st allocator;
extern void
grow_allocator(allocator * a);
extern void *
malloc(size_t size);
void
grow_allocator(allocator * a)
{
 buffer_type_t    *tmp;
 tmp = (buffer_type_t *) malloc(sizeof(buffer_type_t));
 tmp->buffer = (char *) malloc(a->size * a->n);
 tmp->next_buffer = a->buffer_list;
 a->buffer_list = tmp;
 a->next_avail = a->buffer_list->buffer;
 a->last = a->next_avail + (a->size * a->n);
}


The failure occurs in the line:

 a->next_avail = a->buffer_list->buffer;

I am guessing it has to do with the nested member access but I have
not yet been able to work out what the code is doing.

LLVM gives me following error:

Assertion failed: S->getType()->isPtrOrPtrVectorTy() && "Invalid
cast", file C:\d\llvm-3.9.0.src\lib\IR\Instructions.cpp, line 2759

This occurs in calc_memop_addr() function when it tries to do following:

 as = LLVMGetPointerAddressSpace(LLVMTypeOf(src));

If I dump insn, insn->src, and the LLVM value and type before this line, I get:

1) insn load.64     %r18 <- 8[%r2]
2) pseudo %r2
3) store %struct.buffer_type_st* %R2, %struct.buffer_type_st** %26
4) void

The type of the LLVM store instruction is 'void'.

My guess is that something is going horribly wrong in the way member
access is handled.

If you are able to reproduce this and have any suggestions then please
let me know.

Thanks and Regards
Dibyendu
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux