You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5575 Reporter: lealanko Assigned to:@damiendoligez Status: closed (set by @damiendoligez on 2012-04-10T15:33:44Z) Resolution: fixed Priority: normal Severity: minor Version: 3.12.1 Fixed in version: 4.00.0+dev Category: standard library Related to:#5977 Monitored by: mehdi
Bug description
Although the Random module is designed so that it produces the same output on all architectures, the internal representation of a random state depends on the architecture: on 64-bit architectures, the state array contains some values that won't fit into an int on 32-bit architectures. Hence a Random.State.t from a 64-bit system cannot be marshalled and then unmarshalled on a 32-bit system.
This is trivial to fix: just add "land 0x3FFFFFFF" before storing a value in the state array.
let s : Random.State.t = Marshal.from_string "\132\149\166\190\000\000\001~\000\000\000\002\000\000\000;\000\000\000;\160\b\000\000\220\000\003\000\000\000\000\196\146\178\147\003\000\000\000\000\228FXM\002Q'\236\001\002f\239\t\161\002X\195\177F\002P\127W\144\0024r\149\203\003\000\000\000\000\139\133Ro\002K\146K|\002s\196\192)\003\000\000\000\000\173\178\021\209\002\b\194\202\003\000\000\000\000\152\137\186\224\003\000\000\000\000\231e\228\246\002r,,6\002yv\150\244\003\000\000\000\000\250\224\233T\003\000\000\000\000\135}\182\205\003\000\000\000\000\209\168V.\003\000\000\000\000\146\210t\176\002lo\025\003\000\000\000\000\255H8\199\002\017\243\136\188\002HPJx\003\000\000\000\000\228\207*n\002(\184\177Q\003\000\000\000\000\185}\186U\002\015k\206 \003\000\000\000\000\233>\185\222\002-\149\197\194\003\000\000\000\000\243\215[\186\0022=%\138\002-\231\218\025\002g\244\133Z\003\000\000\000\000\169\248\132\202\002d\235+\170\002n\217\147\149\002_\185$!\002c\137\162\200\002:\135fo\002X}\180U\003\000\000\000\000\164[u\234\002G\179\234=\003\000\000\000\000\230\156r\019\003\000\000\000\000\155\252\162\255\003\000\000\000\000\245b9\021\003\000\000\000\000\246\254\198\152\002\t\158R\222\002T\210%\205\003\000\000\000\000\203\252\207\213\003\000\000\000\000\233\011P\219\003\000\000\000\000\171\206\143'\003\000\000\000\000\133\244V\151\002+"\145\165\002\020\139\169\031@" 0;;
Exception: Failure "input_value: integer too large".
The text was updated successfully, but these errors were encountered:
Original bug ID: 5575
Reporter: lealanko
Assigned to: @damiendoligez
Status: closed (set by @damiendoligez on 2012-04-10T15:33:44Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.12.1
Fixed in version: 4.00.0+dev
Category: standard library
Related to: #5977
Monitored by: mehdi
Bug description
Although the Random module is designed so that it produces the same output on all architectures, the internal representation of a random state depends on the architecture: on 64-bit architectures, the state array contains some values that won't fit into an int on 32-bit architectures. Hence a Random.State.t from a 64-bit system cannot be marshalled and then unmarshalled on a 32-bit system.
This is trivial to fix: just add "land 0x3FFFFFFF" before storing a value in the state array.
Steps to reproduce
On 64-bit:
Marshal.to_string (Random.State.make [||]) [];;
"\132\149\166\190\000\000\001~\000\000\000\002\000\000\000;\000\000\000;\160\b\000\000\220\000\003\000\000\000\000\196\146\178\147\003\000\000\000\000\228FXM\002Q'\236\001\002f\239\t\161\002X\195\177F\002P\127W\144\0024r\149\203\003\000\000\000\000\139\133Ro\002K\146K|\002s\196\192)\003\000\000\000\000\173\178\021\209\002\b\194
\202\003\000\000\000\000\152\137\186\224\003\000\000\000\000\231e\228\246\002r,,6\002yv\150\244\003\000\000\000\000\250\224\233T\003\000\000\000\000\135}\182\205\003\000\000\000\000\209\168V.\003\000\000\000\000\146\210t\176\002lo
\025\003\000\000\000\000\255H8\199\002\017\243\136\188\002HPJx\003\000\000\000\000\228\207*n\002(\184\177Q\003\000\000\000\000\185}\186U\002\015k\206 \003\000\000\000\000\233>\185\222\002-\149\197\194\003\000\000\000\000\243\215[\186\0022=%\138\002-\231\218\025\002g\244\133Z\003\000\000\000\000\169\248\132\202\002d\235+\170\002n\217\147\149\002_\185$!\002c\137\162\200\002:\135fo\002X}\180U\003\000\000\000\000\164[u\234\002G\179\234=\003\000\000\000\000\230\156r\019\003\000\000\000\000\155\252\162\255\003\000\000\000\000\245b9\021\003\000\000\000\000\246\254\198\152\002\t\158R\222\002T\210%\205\003\000\000\000\000\203\252\207\213\003\000\000\000\000\233\011P\219\003\000\000\000\000\171\206\143'\003\000\000\000\000\133\244V\151\002+"\145\165\002\020\139\169\031@"On 32-bit:
let s : Random.State.t = Marshal.from_string "\132\149\166\190\000\000\001~\000\000\000\002\000\000\000;\000\000\000;\160\b\000\000\220\000\003\000\000\000\000\196\146\178\147\003\000\000\000\000\228FXM\002Q'\236\001\002f\239\t\161\002X\195\177F\002P\127W\144\0024r\149\203\003\000\000\000\000\139\133Ro\002K\146K|\002s\196\192)\003\000\000\000\000\173\178\021\209\002\b\194
\202\003\000\000\000\000\152\137\186\224\003\000\000\000\000\231e\228\246\002r,,6\002yv\150\244\003\000\000\000\000\250\224\233T\003\000\000\000\000\135}\182\205\003\000\000\000\000\209\168V.\003\000\000\000\000\146\210t\176\002lo
\025\003\000\000\000\000\255H8\199\002\017\243\136\188\002HPJx\003\000\000\000\000\228\207*n\002(\184\177Q\003\000\000\000\000\185}\186U\002\015k\206 \003\000\000\000\000\233>\185\222\002-\149\197\194\003\000\000\000\000\243\215[\186\0022=%\138\002-\231\218\025\002g\244\133Z\003\000\000\000\000\169\248\132\202\002d\235+\170\002n\217\147\149\002_\185$!\002c\137\162\200\002:\135fo\002X}\180U\003\000\000\000\000\164[u\234\002G\179\234=\003\000\000\000\000\230\156r\019\003\000\000\000\000\155\252\162\255\003\000\000\000\000\245b9\021\003\000\000\000\000\246\254\198\152\002\t\158R\222\002T\210%\205\003\000\000\000\000\203\252\207\213\003\000\000\000\000\233\011P\219\003\000\000\000\000\171\206\143'\003\000\000\000\000\133\244V\151\002+"\145\165\002\020\139\169\031@" 0;;The text was updated successfully, but these errors were encountered: