Bugs item #3604915, was opened at 2013-02-15 13:29
Message generated for change (Comment added) made by kerneis
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=742140&aid=3604915&group_id=138953
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: CIL core (parser, visitor, etc)
Group: Bug
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jim Grundy (jim_grundy)
Assigned to: Nobody/Anonymous (nobody)
Summary: Legal, but large, static arrays can fail.
Initial Comment:
We've encounterd embedded programs that carve out large static arrays ... and
they compile and run correctly, but CIL can't process them because the array's
are too big.
In particular, CIL appears to use an OCaml int for an array size, but since
OCaml int's are 1) signed 2) 1-bit shorter than machine ints to facilitate fast
garbage collection; it is possible - and we do - have arrays with a size that
is bigger than can be represented with an OCaml int.
Natrually this is a problem in practice only on 32-bit builds, but since all
the pre-combiled Windows OCaml builds are 32-bit the problem occurs.
I believe this to be the cause because if I set the size to be one byte smaller
than the largest 2s complement number representable in 31 bits it works.
Now, "morally", CIL should be able to process any C file that the compiler can
process - but on a 32-bit machine this does break down here. I expect the right
thing to do would be to modify CIL to use Nativeint library for storying array
sizes.
----------------------------------------------------------------------
>Comment By: Gabriel Kerneis (kerneis)
Date: 2013-02-15 14:50
Message:
OK, Jim. I wonder if this is not some legacy check, and everything else
(except lenOfArray and bitsSizeOf et al.) woud work correctly now. Could
you try the stupid following patch, please?
Many thanks,
Gabriel
--- a/src/frontc/cabs2cil.ml
+++ b/src/frontc/cabs2cil.ml
@@ -2839,7 +2839,7 @@ and doType (nameortype: attributeClass) (* This is
AttrName if we are doing
let size = mul_cilint elems (cilint_of_int elsz) in
begin
try ignore(int_of_cilint size)
- with _ -> E.s (error "Length of array is too large")
+ with _ -> ignore (warn "Length of array is too large")
end
| l ->
if isConstant l then
----------------------------------------------------------------------
Comment By: Jim Grundy (jim_grundy)
Date: 2013-02-15 14:24
Message:
Hi Gabriel
We're doing a source-to-source transform using Cil as a library. The error
we are getting is:
Length of array is too large
Which looks like it comes from frontc/cabs2cil.ml/doType
I'm not sure what's going on here ... but my guess is that it is tryng to
compute the size of the array to record it as an attirbute, but the
atributes use OCaml ints rather than 64-bit ints so it won't fit.
The example program is just this - run with a 32-bit OCaml build on a
64-bit Windows machine.
char big_array[1073741824];
int main () {
return 0;
}
All the best
Jim
----------------------------------------------------------------------
Comment By: Gabriel Kerneis (kerneis)
Date: 2013-02-15 14:00
Message:
I meant CIL 1.4, 1.7 does not even exist...
----------------------------------------------------------------------
Comment By: Gabriel Kerneis (kerneis)
Date: 2013-02-15 13:49
Message:
Since CIL 1.7 (I think), length of arrays is stored as a CInt64 when it is
known explicitely. However, Cil.lenOfArray converts it to int
(Cil.bitsSizeOf also has a similar behaviour, see bug 1641570). What are
you trying to do and how does CIL fail exactly when you process these
programs? Could you post a (script to generate) an example program?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=742140&aid=3604915&group_id=138953
------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
is your hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
CIL-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cil-users