Stl vectors and TDatime

I’m having some difficulties with vectors of TDatime. If I run the following code I get an error when i=258. If I increase the reserved memory the error is gone (at least for i<450). However a memory error occurs when I exit root.

[code]{
gROOT->Reset();
gSystem->Load(“libUber”);

#include ;

vector vec;
TDatime date;
date.Set(2005,01,01,00,00,00);

//vec.reserve(500);

for(int i=0;i<450;i++)
{
vec.push_back(date);
cout << i << " " << flush;
}

cout << “\n” << vec.size() << endl;
}[/code]

[quote]% root error.C


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.26/00b 9 February 2010 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

ROOT 5.26/00b (branches/v5-26-00-patches@32288, Sep 03 2010, 19:10:00 on linux)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing error.C…
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 8
3 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 10
7 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12
7 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 14
7 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 16
7 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 18
7 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 20
7 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 22
7 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 24
7 248 249 250 251 252 253 254 255 256 257
*** Break *** segmentation violation
Generating stack trace…
0xb72a1585 in G__exec_asm + 0x3b08 from /usr/lib/root/libCint.so.5.26
0xb72a6c80 in G__exec_bytecode + 0xa4d from /usr/lib/root/libCint.so.5.26
0xb728143c in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__para
m*, int), G__value*, char*, G__param*, int) + 0x55 from /usr/lib/root/libCint.so
.5.26
0xb72a45a7 in G__exec_asm + 0x6b2a from /usr/lib/root/libCint.so.5.26
0xb72a6c80 in G__exec_bytecode + 0xa4d from /usr/lib/root/libCint.so.5.26
0xb728143c in Cint::G__ExceptionWrapper(int ()(G__value, char const*, G__para
m*, int), G__value*, char*, G__param*, int) + 0x55 from /usr/lib/root/libCint.so
.5.26
0xb72a45a7 in G__exec_asm + 0x6b2a from /usr/lib/root/libCint.so.5.26
0xb735fe50 in from /usr/lib/root/libCint.so.5.26
0xb735cf48 in G__exec_statement + 0x9d41 from /usr/lib/root/libCint.so.5.26
0xb72c2fb5 in from /usr/lib/root/libCint.so.5.26
0xb72c3247 in G__exec_tempfile + 0x1a from /usr/lib/root/libCint.so.5.26
0xb736b162 in G__process_cmd + 0x8369 from /usr/lib/root/libCint.so.5.26
0xb7a19a3a in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x3e
0 from /usr/lib/root/libCore.so.5.26
0xb7a13dd7 in TCint::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) +
0xc5 from /usr/lib/root/libCore.so.5.26
0xb794a51b in TApplication::ExecuteFile(char const*, int*, bool) + 0x827 from /
usr/lib/root/libCore.so.5.26
0xb794a8cf in TApplication::ProcessFile(char const*, int*, bool) + 0x2d from /u
sr/lib/root/libCore.so.5.26
0xb7948470 in TApplication::ProcessLine(char const*, bool, int*) + 0x770 from /
usr/lib/root/libCore.so.5.26
0xb704bf70 in TRint::Run(bool) + 0x47c from /usr/lib/root/libRint.so.5.26
0x08048fcf in main + 0x70 from /usr/bin/root.exe
0xb6d8fbee in __libc_start_main + 0xfe from /lib/libc.so.6
Root > Function construct() busy flag cleared
Function push_back() busy flag cleared[/quote]

After setting the reserve to 500:

[quote]% root error.C


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.26/00b 9 February 2010 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

ROOT 5.26/00b (branches/v5-26-00-patches@32288, Sep 03 2010, 19:10:00 on linux)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0]
Processing error.C…
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 8
3 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 10
7 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12
7 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 14
7 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 16
7 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 18
7 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 20
7 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 22
7 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 24
7 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 26
7 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 28
7 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 30
7 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 32
7 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 34
7 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 36
7 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 38
7 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 40
7 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 42
7 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 44
7 448 449
450
root [1] .q
*** glibc detected *** /usr/bin/root.exe: double free or corruption (!prev): 0x0
97c7790 ***[/quote]

Am I missing something simple?

Thanks,
Chris

we will investigate

Rene

Hi,

This is a limitation of the interpreted version of the vector of objects. You need to either compile your script via ACLiC or simply generate the dictionary for the vector. See root.cern.ch/drupal/faq#n627:[code] gROOT->Reset();
gSystem->Load(“libUber”);

#include ;
gInterpreter->GenerateDictionary(“vector”,“TDatime.h;vector”);
vector vec;[/code]

Cheers,
Philippe.

Hi,

The automatic dictionary generation for this case is now fixed in the trunk, thanks for reporting!

Cheers, Axel.