A problem using CVX

I met a headache problem to solve an optimization problem using CVX. The form of my problem in one step is as follows.
minimize (f(x))
subject to
x <= x_max;
x >= 0;
where f(x) is a convex function, x_max is a given parameter, x is the variable. Obviously, this problem is feasible. However, sometimes I got a negative value for x (a small negative) using CVX, and sometimes it ran correctly. In fact, the minimum value of x is 0. After I obtain a negative x, my following optimization problem is no longer a convex problem, which is indeed when x >= 0. That is, the error in this step must lead to a mistake for the following problem.
I don’t know how to deal with this problem, I turn to you for help, many thanks!

Small deviations into optimality are to be expected. If you specify a constraint x >= 0, for instance, then you can sometimes expect x to obtain a small negative value. This is due to the nature of the numerical solvers employed, and you must take that into account in your larger algorithm design.