Boost logo

Boost Users :

Subject: Re: [Boost-users] [Interprocess] updating elements in vector of maps fails in optimized code
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2011-05-11 15:18:39


El 11/05/2011 13:01, Steven Maenhout escribió:
> I'm using Boost 1.46 on Linux x86_64 in combination with gcc version
> 4.5.1. I'm trying to implement a a sparse matrix in a shared memory
> segment as a vector of maps. When trying to update previously inserted
> elements of the matrix, at a certain point, the program either crashes
> or stalls indefinitely. This only occurs if the gcc optimization is set
> higher than O0. If compiler optimizations are completely turned off (so
> using the -O0 switch) the program works as expected.

Please try latest trunk code or continue reading. offset_ptr works
somewhat outside the standard, since it can point from stack to shared
memory and the compiler is allowed to do optimizations that legally
break offset_ptr assumptions.

The only fix is to disallow some optimizations for offset_ptr
set_offset/get_offset code, just like in MSVC. I've inserted some
__attribute__((noinline)) in those functions for Boost 1.47. It would be
glad if you could me know finding the correct way to make offset_ptr
work again in GCC. Maybe we need to insert some asm("") statement to
disallow some interprocedual optimizations.

Some other relative point implementations, like those used in ACE are
not header-only and I think they avoid this kind of problems, although
in theory whole-program optimizations can also hurt.

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net