Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006316OCamlOCaml standard librarypublic2014-02-04 04:122015-05-24 16:57
Assigned Togasche 
PlatformOCaml 4.01.0OSDebianOS Versionwheezy/sid
Product Version4.01.0 
Target Versionafter-4.02.2Fixed in Version 
Summary0006316: Scanf cannot parse large unsigned int64s
DescriptionAny string literal representing an unsigned int64 that is larger than 2^63 cannot be parsed by Scanf.sscanf using the format string "%Lu".
Steps To ReproduceThe following code snippet consistently reproduces the issue:

  Scanf.sscanf "12306459064359371967" "%Lu" (fun i -> i);;
Attached Filespatch file icon diff-ocaml-4.02.1-fix-unsigned-scanf-v1.patch [^] (5,194 bytes) 2015-05-13 11:43 [Show Content]
patch file icon diff-ocaml-4.02.1-fix-unsigned-scanf-v2.patch [^] (3,522 bytes) 2015-05-13 11:44 [Show Content]

- Relationships
related to 0006649feedback int_of_string fails on integers starting with a + 

-  Notes
doligez (administrator)
2015-05-12 17:36

@gasche: shouldn't we postpone this one to 4.03?
gasche (developer)
2015-05-12 17:42

Reasonable. I will postpone it so that it doesn't block the release, but if a patch comes in time, and is safe, I will be tempted to merge it in 4.02.
bvaugon (developer)
2015-05-13 11:44

I attatch two patches that fix the problem with two different solutions :
  * Version 1: OCaml implementation of unsigned_{int,int32,int64,nativeint}_of_string
    + Pure OCaml (improved portability)
    + Faster than C implem (surprisingly, or not ^^)
    - Code replication to manage int, int32, int64 and nativeint
    - Increase code size
  * Version 2: extend int_of_string functionnality with "0u1234" syntax (for unsigned ints)
    + Little code modification
    + Extend int_of_string functionalities
    - A bit slower and less readable

Any opinion?
gasche (developer)
2015-05-13 13:37

The first patch is too invasive for 4.02, but could be an option for 4.03 (but it's not clear to me why we would write the unsigned parsing functions in OCaml, and keep the signed parsing in C). The second patch seems reasonable, I'd like the opinion of our release manager.
bvaugon (developer)
2015-05-13 14:10

In fact, since the OCaml implementation of int_of_string'like functions seems to be (between 1.5 and 2 times) faster than the current C implementation (on some machines, maybe not anywhere), it might be interresting (also for portability, homogeneity and simplicity) to encode all of them in OCaml.

The first version principally adds code, and contains modifications of only few lines of the existing ml code. IMHO, it seems safer to release it than the second version that modify the existing C code, except if the syntax "0u..." is considered interesting for int_of_string.

I forgot to tell that this patch also fix "%u", "%lu" and "%nu".

- Issue History
Date Modified Username Field Change
2014-02-04 04:12 seliopou New Issue
2014-06-19 17:51 gasche Tag Attached: junior_job
2014-07-16 10:33 doligez Status new => acknowledged
2014-07-16 10:33 doligez Product Version => 4.01.0
2014-07-16 10:33 doligez Target Version => 4.02.1+dev
2014-09-04 00:25 doligez Target Version 4.02.1+dev => undecided
2014-09-15 12:40 doligez Target Version undecided => 4.02.2+dev / +rc1
2015-05-06 15:22 gasche Assigned To => gasche
2015-05-06 15:22 gasche Status acknowledged => assigned
2015-05-12 17:36 doligez Note Added: 0013909
2015-05-12 17:42 gasche Note Added: 0013910
2015-05-12 17:42 gasche Target Version 4.02.2+dev / +rc1 => after-4.02.2
2015-05-13 11:43 bvaugon File Added: diff-ocaml-4.02.1-fix-unsigned-scanf-v1.patch
2015-05-13 11:44 bvaugon File Added: diff-ocaml-4.02.1-fix-unsigned-scanf-v2.patch
2015-05-13 11:44 bvaugon Note Added: 0013912
2015-05-13 13:37 gasche Note Added: 0013914
2015-05-13 14:10 bvaugon Note Added: 0013915
2015-05-24 16:57 gasche Relationship added related to 0006649

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker